Getting a thread to throw an exception
Sorry if this is in the wrong place, can a mod move it if it is?
Is it possible to get the run method inside a thread to throw an exception?
If I describe the problem maybe I can get some advice on a different way to go about this.
I have a main class class1 which creates a thread (class2) and executes some code within a timelimit. If class1 takes too long the thread should throw back an exception.
Class2 myThread = new Class2();
// do some stuff here within timelimit
catch (Exception e)
The best I can do it to get the thread to print "time out" when the timelimit
is over and class1 is still executing.
The problem is, the run method of a thread cannot throw exceptions.
Is there a way around this? Is there a better to go about what I'm doing?