Originally posted by Angela Narain:
[B]Hi,
I tried out the following code and started two threads
which share the same object "MyThread" as shown below :
[This message has been edited by Angela Narain (edited October 04, 2001).][/B]
This can not work. Once you are into the callMe function, you will never see wait == false. This is because the lock will not be released by the FIRST thread to acquire it, untill the thread is done and leaving the method. The next thread to grab the lock will always be faced with wait == true. Did you ever see the "waiting" message?
You need something slightly different
That should do what you seek. Do you understand the difference here?