This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads state Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads state" Watch "Threads state" New topic
Author

Threads state

Girish Nagaraj
Ranch Hand

Joined: Apr 19, 2006
Posts: 153
Assume that a set of threads are accessing the same object in synchronization.

What will be the state of other threads when one of thread has acquired Lock of that object?
Shaliey Gowtham
Ranch Hand

Joined: Mar 20, 2006
Posts: 104
Blocked state
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Blocked
Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
What will be the state of other threads when one of thread has acquired Lock of that object?


Won't the thread be in waiting state


"Know where to find the solution and how to use it - that's the secret of success."
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Nope! It is blocked.

See JDK API

This will prove it.

Pramila Chinguru
Ranch Hand

Joined: May 05, 2006
Posts: 54
Hi
There are only five states a thread can be in.
new,runnable,running,blocked,dead.
Blocked state includes when a thread is put to sleep using sleep method, or when a thread is waiting for an object lock is blocked using wait/notify protocol.
Go through this tutorial. Hope that helps.
Ashok S Yadav
Greenhorn

Joined: May 04, 2006
Posts: 5
pramila,
The link that you have inserted in your message takes me to a page that says that a thread can be in one of the four states:
1. New
2. Runnable
3. Dead
4. Blocked.
Any thoughts on this. I am working my 1.4 certification. Thread is one topic that is really giving me headaches.

Thanks
Pramila Chinguru
Ranch Hand

Joined: May 05, 2006
Posts: 54
Hi Ashok,
Any thread which is ready for execution(waiting for CPU time) would be kept in runnable pool. Once it gets CPU time(currently executing) then it is in Running state.
 
jQuery in Action, 2nd edition
 
subject: Threads state
 
Similar Threads
stack memory
Notify method
Problem with kathy sierra book
To declare Syncronized or Not, always the question!
notifyall