logger.debug("Leaving");
}
public static final void wait(java.lang.Object callingObject, long millis) throws InterruptedException {
logger.debug("Entering");
Controller controller = AgentJVirtualMachine.getCurrentNS2NodeController();
logger.trace("Wait wait("+millis+") on Node " + controller.getLocalHost() );
logger.trace("Calling Object = " + callingObject.getClass().getName());
java.lang.Thread awaitThread = Thread.currentThread();
String threadName = awaitThread.getClass().getName();
// keep all logic in the created WaitInvocation to keep thread safety here and
// remove the need for more locks
WaitInvocation waitObj = new WaitInvocation(controller);
ObjectCounter objctr = getObject(callingObject);
if (objctr!=null) {
objctr.increment();
} else {
logger.trace("Adding a new object to Vector for " + callingObject.getClass().getName());
ObjectCounter ob=new ObjectCounter(1,callingObject);
ob.setWaitInvocationObject(waitObj);
objectsWaiting.add(ob);
}
// kick off timer first...
waitObj.kickOffWaitTimer(millis);
Logging.monitorStatus(controller, Logging.MonitorStatusType.WAIT, threadName);
controller.getThreadMonitor().threadPaused(threadName); // we are stopping ...
waitObj.agentJWait(callingObject); // returns when done ...
Logging.monitorStatus(controller, Logging.MonitorStatusType.RELEASED, threadName);
// if (!waitObj.getWasTimedOut())
controller.getThreadMonitor().threadContinued(threadName); // timed out objects already have added one to threadcount
synchronized(callingObject) {
callingObject.notify(); // to release notify method ....
}
// ProtolibTimer timer = new ProtolibTimer(controller, 0, 0);
// timer.startTimerAndBlockUntilTimeout(); // and stopping