This method runs within the time-critical Timer Dispatcher thread and
is not intended to be called by users. It is defined public only because
is part of the <code>TimerListener</code> interface.
*/
public void doTimeOut(Timer t) {
Behaviour b = null;
// This synchronized block avoids that if a behaviour is blocked
// again just after pendingTimers.getPeer(t) is called, a new mapping
// is added before the old one is removed --> The new mapping is
// removed instead of the old one.
// In any case b.restart() must be called outside the synchronized
// block to avoid a deadlock between the TimerDispatcher and the Scheduler.
synchronized (theDispatcher) {
b = pendingTimers.getPeer(t);
if(b != null) {
pendingTimers.removeMapping(b);
}
}
if(b != null) {
b.restart();
}
else {
System.out.println("Warning: No mapping found for expired timer "+t.expirationTime());
}
}