Posted By:
David_Bates
Posted On:
Thursday, June 19, 2003 05:56 AM
PS - Do your own homework next time and stop wasting everyone's time.
Posted By:
David_Bates
Posted On:
Thursday, June 19, 2003 05:55 AM
"two threads that execute simultaneously inside synchronized methods of the same object"
This isn't possible. In order for a thread to execute any synchronized code, it must first obtain the object lock. Only one thread may do this at a time. It is therefore impossible for two threads to be simulatneously inside synchronized methods of the same object.
Posted By:
Stijn_Fonck
Posted On:
Wednesday, June 18, 2003 02:09 PM
Answer is 2: Coordination of threads is always done via wait and notify.
I you put a thread asleep, you aren't sure which other thread gets executed (it could also be the gc which starts executing).
Thread.yield() will try to see if there are some thread waiting with a higher priority, if not, this thread will restart executing eventually