I am fairly new to Java threads, Runnable, and the like. As such, I'm wondering why the following code does not catch an exception?
Runnable r = () -> {
try {
job.print();
} catch (Exception e) {
e.printStackTrace();
}
};
if (job.printDialog()) {
Thread t = new Thread(r);
r.start();
}
Reading Is there a way to make Runnable's run() throw an exception I gather that:
- "... if your run() method is really the target of a Thread, there's no point in throwing an exception because it is unobservable; throwing an exception has the same effect as not throwing an exception (none)." (@erickson)
- I should check for exceptions inside the Runnable.run() method.
Why is that? Any "simple" explanations on this matter are highly appreciated!