public void stop() {
   StoppableExecutor executor;
   lock.lock();
   try {
     executor = this.executor;
   } finally {
     lock.unlock();
   }
   if (executor != null) {
     executor.stop();
   }
 }
 private void stopConsuming() {
   StoppableExecutor executor;
   lock.lock();
   try {
     stdin.clear();
     removed = true;
     condition.signalAll();
     executor = this.executor;
   } finally {
     lock.unlock();
   }
   if (executor != null) {
     executor.stop();
   }
 }
Exemple #3
0
 /**
  * Requests that this message hub stop. First requests stop as per {@link #requestStop()}, then
  * blocks until stop has completed. This means that:
  *
  * <ul>
  *   <li>All calls to {@link Dispatch#dispatch(Object)} for outgoing messages have returned.
  *   <li>All dispatches to handlers have completed.
  *   <li>All internal threads have completed.
  * </ul>
  */
 public void stop() {
   try {
     lock.lock();
     try {
       requestStop();
     } finally {
       lock.unlock();
     }
     workers.stop();
   } finally {
     lock.lock();
     try {
       state = State.Stopped;
     } finally {
       lock.unlock();
     }
   }
 }