Hi Guys,
Here is the piece of code
synchronized(LOCK) {
Thread.sleep(1000); // LOCK is held
}
.
We know that the sleep method() does not release the lock. Hence, no other object can access the above piece of code even
if this thread is asleep. So, I am confused why is sleep used in this context! sleep() is used to give other threads a chance to get back into
runnable( or may be running). Aint't it?
Please help.
Thanks
Faisal
Here is the piece of code
synchronized(LOCK) {
Thread.sleep(1000); // LOCK is held
}
.
We know that the sleep method() does not release the lock. Hence, no other object can access the above piece of code even
if this thread is asleep. So, I am confused why is sleep used in this context! sleep() is used to give other threads a chance to get back into
runnable( or may be running). Aint't it?
Please help.
Thanks
Faisal