aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes threads! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "threads!" Watch "threads!" New topic
Author

threads!

ashok khetan
Ranch Hand

Joined: Jul 29, 2001
Posts: 153
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
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

------------------
author of:


Java Resources at www.wbrogden.com
ashok khetan
Ranch Hand

Joined: Jul 29, 2001
Posts: 153
William!
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??
ashok.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Bill's answer is correct.
I think you need read this article: http://java.sun.com/products/jdk/1.2/docs/guide/misc/threadPrimitiveDeprecation.html
For more help on thread, all thread:
http://www.webappcabaret.com/javachina/faq/05.htm
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9033
    
  10
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
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
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.
 
subject: threads!
 
Similar Threads
DAEMON THREAD
Single session, two applications?
Understanding the Thread reference that is returned by call to Thread.currentThread();
daemon thread & user thread
Threads