Yeah Megha,
Did you see the behavior of your code by removing synch from the run method
of the SleepingThread class.
As I know, if the sleep() method is called from the sync block, sleep() does not release the lock, at least until it wakes up and it is also not guaranteed that after waking it will immediately release the lock.
I think there is nothing to do with sleep(...); it is all about the sync block, no two threads can acquire the same sync block together is the known
fact; if the thread, in which sleep(...) is executing, is acquiring the lock, how can notify be executed on the same object block.
Thread expert Henry Wong, is not available for so long. He could help us to get the things clearly...
Anyways, Megha, your code gives some idea to me! (Thanks for that)
Regards,
cmbhatt
[ April 28, 2007: Message edited by: Chandra Bhatt ]