Mike Gershman
SCJP 1.4, SCWCD in process
SCJP, SCJD, SCWCD, SCBCD
Thread1 gets the lock, prints the message, issues a useless notify, releases the lock, gets the lock again, and waits (this releases the lock).
Thread2 gets the lock, prints the message, issues a notify, and releases the lock.
Thread1 gets the lock again, releases the lock, and finishes.
Thread2 gets the lock and waits forever because Thread1 already issued its notify.
Ramaseshan T<br />SCJP 1.4
Originally posted by Animesh Shrivastava:
So, does this mean that if wait() is invoked, there has to be a notify for it or else the code gets stuck.
Am i right?
Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.
In the first point u have said at the end the Thread 1 gets the lock again, and waits()(this releases the lock)
how is this possible?
I came to know that there are two thread objects created, these threads are not sharing a common object. They both are running on different objects. So ur fourth point looks non existing. Am i right?
Mike Gershman
SCJP 1.4, SCWCD in process