This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Wating/blocking/sleeping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Wating/blocking/sleeping" Watch "Wating/blocking/sleeping" New topic
Author

Wating/blocking/sleeping

Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
Is a thread considered to be alive while it is in one of these 3 states.

I thought they shouldn't be because they are not in runnable state. But i read in a book that thread in blocked state is alive.
Why is it so and what about other states?

thanks
Swamy Nathan
Ranch Hand

Joined: May 16, 2004
Posts: 187


The Life Cycle of a Thread

not runnable=Wating/blocking/sleeping

The isAlive method returns true if the thread has been started and not stopped. If the isAlive method returns false, you know that the thread either is a New Thread or is Dead. If the isAlive method returns true, you know that the thread is either Runnable or Not Runnable. You cannot differentiate between a New Thread or a Dead thread. Nor can you differentiate between a Runnable thread and a Not Runnable thread.


Read all about it at

http://java.sun.com/docs/books/tutorial/essential/threads/lifecycle.html
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Wating/blocking/sleeping