Author | Topic: Uncaught exception |
Ajith Kallambella ranch hand |
posted May 05, 2000 07:44 AM
Hi folks, This is a conceptual question. Assume there are two user threads U1 and U2 that
As I understand, uncaught exceptions I really appreciate your inputs.
|
Eric Barnhill ranch hand |
posted May 06, 2000 12:00 AM
My understanding is that an uncaught exception causes the system to exit. Presumably that would take all the threads with it, if I have the right concept of system exit. Eric
|
vishwas kumar bansal unregistered |
posted May 06, 2000 03:26 PM
Exception must be caught somewhere.If a exception is throwned by a thread u1,either it must be catch into thread u1 or it must caught in the calling portion of u1.If the thread remains uncaught and no throws statement is included in main of main thread the exception is passed to jvm which terminate the main thread and the corresponding threads.
|
maha anna bartender |
posted May 07, 2000 02:53 PM
Ajith, In order to convert your conceptual qstn into a practical one I wrote this foll prog. PLease cut and paste this code and analyze. It seems to me that If a program spawns user therad1 U1, and another user thread U2, then if user thread U1 throws an Exception, if it was not caught, the uncaughtException of the user thread U1's ThreadGroup is called, if that method does not catch this Exception, then it is propagated to this ThreadGroup's parent ThreadGroup's uncaughtException method and so on and finally if there is no one to care about then the JVN forms a UncaughtException object and gives to System.err which prints to our console. But the other User thread continues to do its work without any problem. And the JVM also DOES NOT EXIT because there is one more NO-PROBLEM user thread for it to care about. regds maha anna
[This message has been edited by maha anna (edited May 07, 2000).]
|
Eric Barnhill ranch hand |
posted May 07, 2000 10:05 PM
My output here: ---- Starting therad 1.... Starting therad 2.... Last statement of main(..) method Thread-1 Thread-2 Thread-1 Thread-2 Thread-1 Thread-2 java.lang.RuntimeException at myThread2.run (Compiled Code) Thread-1 Thread-1 Thread-1 [other 94 instances of "Thread-1" omitted]
|
| | |