Page 1 of 1

About Question enthuware.ocpjp.v7.2.1522 :

Posted: Sun Mar 24, 2013 12:00 pm
by alex
I am bit confused about the following sentence.
Thread T1 holds the lock for an object obj. Thread T2 has called obj.wait() and is blocked.

How could it happen?
How could they keep lock on the same obj at the same time? To call obj.wait() T2 have to hold te lock for an obj.

Then answer: Thread T1 releases the lock on obj and calls the notify() method on obj.
How could lock release happen before notify(). It it happens then we will not be able to call notify() without exception.

Please explain this issue.

Re: About Question enthuware.ocpjp.v7.2.1522 :

Posted: Sun Mar 24, 2013 12:22 pm
by admin
You are right. Both the statements should actually be reversed.
This has now been updated.

thank you for your feedback!