[cpp-threads] Re: Exception propogation across threads
Chuck Allison
chuck at freshsources.com
Thu Feb 22 19:10:15 GMT 2007
> * Not positive, but I believe java defaults to thread-only termination
> but with a stack trace printed to the console.
> http://java.sun.com/docs/books/jls/second_edition/html/exceptions.doc.html
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ThreadGroup.html#uncaughtException(java.lang.Thread,%20java.lang.Throwable)
Here is more specific language from the Java 1.5 doc (note: every thread in
Java belongs to a thread group):
"When a thread is about to terminate due to an uncaught exception the Java
Virtual Machine will query the thread for its UncaughtExceptionHandler using
Thread.getUncaughtExceptionHandler() and will invoke the handler's
uncaughtException method, passing the thread and the exception as arguments.
If a thread has not had its UncaughtExceptionHandler explicitly set, then
its ThreadGroup object acts as its UncaughtExceptionHandler. If the
ThreadGroup object has no special requirements for dealing with the
exception, it can forward the invocation to the default uncaught exception
handler"
It is the default uncaught exception handler that prints a stack trace to
System.err and terminates the thread.
-- Chuck Allison.
More information about the cpp-threads
mailing list