aspose file tools
The moose likes Threads and Synchronization and the fly likes After wait shoudln't thread be in blocking state rather than runnable state? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "After wait shoudln Watch "After wait shoudln New topic
Author

After wait shoudln't thread be in blocking state rather than runnable state?

Harish Kommaraju
Greenhorn

Joined: Nov 10, 2009
Posts: 13
Hi,

I am going through SCJP 6 book by Kathy Sierra & Bert Bates. A sample code snippet is given below from Threads chapter, where I need a clarification


Now my doubt is, after 2 seconds of wait time, to continue further code execution, the above code would require the lock on object 'a' and there is fair chance that the other thread (which is supposed to call notify() on a) might already be holding a lock on it.

So shouldn't the thread go to Blocking state after 2seconds wait, instead of Runnable state as mentioned above in the comments (in Line No. 2).

Kindly clarify what am I missing here.

Thanks & Regards,
Harish
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2782
    
    2
Yes, you are entirely correct. The thread must go to Blocking, and reacquire the lock, before it enters Runnable.
Harish Kommaraju
Greenhorn

Joined: Nov 10, 2009
Posts: 13
Thanks Mike for the confirmation. I will try to inform the authors to make this correction, as it could confuse newbies.

Can any one please let me know how can I intimate SCJP 6 authors (Kathy / Bert) regarding this correction? Is there any separate group for that in this forum?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: After wait shoudln't thread be in blocking state rather than runnable state?
 
Similar Threads
K & B question 6 chapter 9(Threads).
Thread states and Object lock
Thread Question
Wait with timeout
Java Thread Question