05-05-2012 04:31 PM
If 2 different threads issues a notify "simultaneus" will the wait always be capable to "fetch" both notifies?
05-05-2012 06:07 PM - edited 05-05-2012 06:07 PM
On the same object? I think you have to use a sync block around calls to wait and notify, so one would be called before the other, and if there are no other threads waiting on that object, the second notify should get ignored.
05-06-2012 03:23 AM
3 parts involved The main task and several different threads. In theory the threads cannot execute the notify at the "same" time since there is sync block around the notify code. In practice the notyfies could be coming very close in time. I would assume, but do not know that the waiting task has priority or will react instantly to the first notify and that will cause the second notify to wait fon the synch.
The first notify is in the synch block, the second notify is hanging and waiting on the sync and the wait code is hanging and waiting on the wait statement . When the first notify releases the sync is the wait code the first to get control? I really hope so.
public void run()
V_TestVector.wait(CMDwaitms); //Ownership released
synchronized(V_TestVector) //Regain ownership Might not be needed here. Not sure
NotifyStringV = (String) V_TestVector.elementAt(0); //Get return values
} //end synchronized
} //end synchronization
HandleAlert(_Setup.Error,"ReplytoCmndsWait error: "+ e33,0);
And the notify code has it like this
}catch (Exception E1)