/** * Used in synchronous mode only. Provides a hook that enables a synchronous operation on a * previously sent inform request. Only one inform request can be in synchronous mode on a given * thread. The blocked thread is notified when the inform request state reaches completion. If the * inform request is not active, the method returns immediately. The user must get the error * status of the inform request to determine the exact status of the request. * * @param time The amount of time to wait. Zero means block until complete. * @return <CODE>true</CODE> if the inform request has completed, <CODE>false</CODE> if it is * still active. */ public final boolean waitForCompletion(long time) { if (!inProgress()) // check if request is in progress. return true; if (informSession.thisSessionContext()) { // We can manipulate callback safely as we are in session thread. // SnmpInformHandler savedCallback = callback; callback = null; informSession.waitForResponse(this, time); callback = savedCallback; } else { // This is being done from a different thread. So notifyClient will do the notification. // synchronized (this) { SnmpInformHandler savedCallback = callback; try { callback = null; this.wait(time); } catch (InterruptedException e) { } callback = savedCallback; } } return (!inProgress()); // true if request completed. }