public synchronized boolean suspendContinuationIfNeeded() {
   if (!cont.isPending() && !resumedByApplication) {
     initialSuspend = false;
     cont.suspend(AsyncResponse.NO_TIMEOUT);
     return true;
   } else {
     return false;
   }
 }
 public synchronized void handleTimeout() {
   if (!resumedByApplication) {
     if (pendingTimeout != null) {
       setAsyncResponseOnExchange();
       cont.suspend(pendingTimeout);
       pendingTimeout = null;
     } else if (timeoutHandler != null) {
       timeoutHandler.handleTimeout(this);
     } else {
       cont.setObject(new ServiceUnavailableException());
     }
   }
 }
 @Override
 public synchronized boolean setTimeout(long time, TimeUnit unit) throws IllegalStateException {
   if (isCancelledOrNotSuspended()) {
     return false;
   }
   setAsyncResponseOnExchange();
   long timeout = TimeUnit.MILLISECONDS.convert(time, unit);
   initialSuspend = false;
   if (!cont.isPending()) {
     cont.suspend(timeout);
   } else {
     pendingTimeout = timeout;
     cont.resume();
   }
   return true;
 }