True or False: a user thread can't stop a non-user or daemon thread.
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12266
1
posted
0
The daemon thread flag doesn't have anything to do with being able to stop a Thread. It just affects the rule for stopping the JVM when there are no more user threads. Bill
Originally posted by ashok khetan: i think my question is different than what u have answered..the question states whether a USER thread can stop the non-daemon or not??
A User thread can stop another user (non-daemon) thread. A User thread can stop a daemon thread. However, stop() has been deprecated.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Roseanne Zhang
Ranch Hand
Joined: Nov 14, 2000
Posts: 1953
posted
0
The key concept here is The question is irrelavent, as Bill indicated. Marilyn Your answer is not completed, since any thread can stop any thread but it is unsafe to do so. User thread can become deamon thread too. No more explainations is a better explaination for this question. The better question would be how to stop a thread w/o call stop() method. This is out of SCJP scope, of course. However, it is very practical. [This message has been edited by Roseanne Zhang (edited September 16, 2001).]
Roseanne Zhang
Ranch Hand
Joined: Nov 14, 2000
Posts: 1953
posted
0
You threads are default to user thread unless you explicitly use method setDaemon(boolean on) to set it as daemon thread. Note: You cannot call setDaemon() after Thread has started, otherwise, an IllegalThreadStateException (RuntimeException) will be thrown.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.