| 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
|
|
|
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?
|
 |
 |
|
|
subject: After wait shoudln't thread be in blocking state rather than runnable state?
|
|
|