Caution: this may not suit your needs if you need to use an exception mechanism.
If you understand correctly, you really do not need to check the exception (you accepted the answer suggesting the exception), and a simple listener template would be more suitable?
The listener can live in the parent thread, and when you catch the checked exception in the child thread, you can simply notify the listener.
This means that you have a way to show that this will happen (using publicly available methods) and be able to pass more information than the exception allows. But this means that there will be a connection between the parent and child stream (albeit free). In your specific situation, it will depend on whether this takes precedence over throwing a checked exception with an unchecked exception.
Here is a simple example (some code borrowed from another answer):
public class ThingRunnable implements Runnable { private SomeListenerType listener;
The relationship comes from an object in the parent thread, which must be of type SomeListenerType .
Grundlefleck Sep 02 '09 at 20:03 2009-09-02 20:03
source share