Originally posted by Ajay Xavier:
what is the race condition yor are discussing about?
As incredibly unlikely as it is, it is theoretically possible for the new
thread to start, finish the task, and send the notification, before the main thread calls the wait() method.
You should (1) setup some sort of "done" flag, which is set just prior to sending the notification, and (2) check the flag, before actually waiting. And of course, the setting and checking of the flag should be done within the synchronized blocks.
Henry