I am creating some multi-threaded code, and I have created a JobDispatcher class that creates threads. I want this object to handle any unhandled exceptions in the worker threads, and so I am using
Thread.setUncaughtExceptionHandler(this);
Now, I would like to test this functionality – how can I generate an unhandled exception in the run() method of my worker object?
Just throw any exception.
E.g.:
Complete: