This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Not on block either. The only ways I remember that a lock on a monitor is given up are: (1) when the synchronized method or block ends, and (2) when the monitor's wait() method is called (it's then re-acquired after notify() in order for the thread to resume in synchronized code).
A thread gets blocked - by calling sleep(x); - by calling suspend() (deprecated); - by calling wait(); - due to I/O block - while waiting for an object lock or "monitor" The thread which has acquired the lock and is in critical section would not give up the lock when it calls sleep(), suspend() or when its blocking for i/o. The thread would give up the lock when the object it is locking on calls wait(), SO I think you are correct. sleep() and yield() are Thread methods and blocking is a consequence of an operation. So they cannot influence the lock acquired by an Object.
Originally posted by James: Friends: Does the thread lose the monitor on sleep, yield or block. I feel it does not. Can some one confirm this. James