Reputation: 101
Lets assume a situation like this :
Lets say Thread0
access the lockObject
first and then Thread0
going to sleep for 1000ms.
synchronized(lockObject) {
Thread0.sleep(1000);
}
Thread1
also waiting for access the lockObject
.
What happened in these kind of situations? Is that context switching will pause for 1000ms because of the sleep(1000)?
Upvotes: 0
Views: 737
Reputation: 7175
When you call Thread0.sleep(1000);
, the thread does not release the lock on lockObject
. So yes context switching will pause for 1000ms.
Upvotes: 1