Shutting down a thread instantly - should this work?
John McParland
Ranch Hand
Joined: May 11, 2009
Posts: 83
posted
0
Hi folks,
in my application, when a user chooses to shutdown, I need to stop a few threads instantly which may have be sleeping. I think I have a solution for this but unfortunately there are folks who've noticed the thread is still running when the app has been shut down. I can't reproduce this behaviour and I was wondering if anyone would kindly have a look at the code below to see if there's anything obviously wrong?
The code to start the thread is;
And the code to stop is;
Passed: SCJP 6 (90%), SCJD 6
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 11862
posted
0
Seems to me that if you make all these other Threads daemon threads then the JVM will automatically stop them when your main user Threads exit.