C
christopher
Greetings!
I am sure there is a simple answer to how to terminate a thread when
main throws an error.
if it matters, all main does is instantiate its object so I can do non-
static stuff. The thread implements runnable and the constructor for
the object that contains 'main' spins the thread like this:
sThread=new SocketThread(controlSocket);
Thread t = new Thread(sThread);
t.start();
the SocketThread checks a local variable every 2 seconds or so and has
a method for setting that variable so the thread will gracefully
terminate when main ends properly.
If I have an uncaught runtime error the thread keeps the JVM alive
indefinitely.
Do I need to wrap the constructor in a 'try' block (or main?), or is
there a better way?
BTW, tried searching for this but the terms are too generic :<(
Thanx!
-- clh
I am sure there is a simple answer to how to terminate a thread when
main throws an error.
if it matters, all main does is instantiate its object so I can do non-
static stuff. The thread implements runnable and the constructor for
the object that contains 'main' spins the thread like this:
sThread=new SocketThread(controlSocket);
Thread t = new Thread(sThread);
t.start();
the SocketThread checks a local variable every 2 seconds or so and has
a method for setting that variable so the thread will gracefully
terminate when main ends properly.
If I have an uncaught runtime error the thread keeps the JVM alive
indefinitely.
Do I need to wrap the constructor in a 'try' block (or main?), or is
there a better way?
BTW, tried searching for this but the terms are too generic :<(
Thanx!
-- clh