| Author |
when a thread is in sleep...
|
krishna Gajarla
Greenhorn
Joined: Oct 02, 2005
Posts: 21
|
|
hai all, This is the question i faced in an interview. when the thread is in sleep ex if t.sleep(100) is there in your code does it hold the monitor? i said yes...is it true?? i need the correct explanation from any of you... thanks in advance rk
|
Thanks and Regards,<br />krishna<br />------------------<br />Charles Darwin: <br />"It is not the strongest of the species that survives, <br />nor the most intelligent, <br />but the one most responsive to change"
|
 |
Peter Chase
Ranch Hand
Joined: Oct 30, 2001
Posts: 1970
|
|
sleep() has nothing to do with synchronisation. If the thread had the monitor before sleep(), it has it during sleep(). If it didn't have it before sleep(), it doesn't have it during sleep(). In contrast, wait() requires the thread to have the lock before wait(), and releases the lock while waiting. A bartender will very shortly be complaining that your login name "kris" does not comply with the JavaRanch standards. To avoid that, go change it now.
|
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
|
 |
krishna Gajarla
Greenhorn
Joined: Oct 02, 2005
Posts: 21
|
|
|
Thank you Peter...
|
 |
 |
|
|
subject: when a thread is in sleep...
|
|
|