Java: Exception in a child thread
exception, java
Solution
Short answer, it doesn't. If the exception propagates all the way out of the thread, it'll simply die (possible generating some error print on the console).
What you might be interested in doing though is to catch all exceptions in your outermost stack frame (i.e. your run-method, which started the thread), which puts the exception on a queue or other communication mechanism (perhaps along with some meta data such as thread id, etc) before the thread is terminated. The queue is then queried regularly by the parent thread (or use some other notification mechanism to wake up the parent thread, such as wait/notify or Condition-objects).
Problem
in Java, if i start a thread T, from a main method in class A, and an exception occurs in T, how will the main method in A know about this. If im not wrong, an instance of Class A and the thread T will be present in two separate stacks, right, so, how does the parent of the thread get to know about the exception ?