anyObject.wait(maxDuration)^ static Thread.sleep(howLong)

It’s instructive to compare these 2. See P71 [[Java Threads]].

During sleep(), the sleeping thread doesn’t release lock. In fact, sleep() is a static method with no object mentioned.

I think *inside*[1] the myObj.wait() JVM takes the lock off the current thread. Immediately before/after wait(), current thread must possess the lock on myObj. thread blocks until this happens.

[1]right after we enter myObj.wait() and right before we exit myObj.wait().

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s