Handles doomed threads.<p>
167278
protected void handleDoomedThreads() {

        try {
            Iterator<CmsUUID> i = m_threads.keySet().iterator();
            Set<CmsUUID> doomed = new HashSet<CmsUUID>();
            // first collect all doomed Threads
            while (i.hasNext()) {
                CmsUUID key = i.next();
                A_CmsReportThread thread = m_threads.get(key);
                if (thread.isDoomed()) {
                    doomed.add(key);
                    if (LOG.isDebugEnabled()) {
                        LOG.debug(
                            Messages.get().getBundle().key(
                                Messages.LOG_THREADSTORE_DOOMED_2,
                                thread.getName(),
                                thread.getUUID()));
                    }
                }
            }
            i = doomed.iterator();
            // no remove all doomed Threads from the Thread store
            while (i.hasNext()) {
                m_threads.remove(i.next());
            }
            if (LOG.isDebugEnabled()) {
                dumpThreads();
            }
        } catch (Throwable t) {
            // the Grim Reaper must not be stopped by any error
            LOG.error(Messages.get().getBundle().key(Messages.LOG_THREADSTORE_CHECK_THREADS_ERROR_0), t);
        }
    }
1353768
public void handle(Throwable t) {
    System.out.flush();
    System.err.println(t.getClass().getSimpleName() + ":" + t.getMessage());
    if (debug)
      t.printStackTrace();
  }
1149412
private void stop() {
        finish(inputThread);

        try {
            err.flush();
        } catch (IOException e) {
            // ignore
        }
        try {
            out.flush();
        } catch (IOException e) {
            // ignore
        }
        finish(outputThread);
        finish(errorThread);
    }
40721
private void handleRequestFailure(long requestId, Throwable error, ThreadContext context) {
    ByteBuf buffer = channel.alloc().buffer(10)
      .writeByte(RESPONSE)
      .writeLong(requestId)
      .writeByte(FAILURE);

    try {
      writeError(buffer, error, context);
    } catch (SerializationException e) {
      return;
    }

    channel.writeAndFlush(buffer, channel.voidPromise());
  }
364029
public static void safelyIgnoreException(Throwable t)
    {
        if (t instanceof ThreadDeath)
        {
            throw (ThreadDeath) t;
        }

        if (t instanceof OutOfMemoryError)
        {
            throw (OutOfMemoryError) t;
        }

    }
998056
void submit() {

        try {
            List<CmsUUID> modifiedResources = undelete();
            m_context.finish(modifiedResources);
        } catch (Exception e) {
            m_context.error(e);
        }
    }
105332
public void stopThreads()
    {
        if (threadMap.isEmpty())
        {
            throw new IllegalStateException("threads are already interrupted");
        }
        lock.lock();
        try
        {
            Thread currentThread = Thread.currentThread();
            for (Thread thread : threadMap.values())
            {
                if (!currentThread.equals(thread))
                {
                    thread.interrupt();
                }
            }
            threadMap.clear();
            semaphoreMap.clear();
        }
        finally
        {
            lock.unlock();
        }
    }
1306755
public void uncaughtException(Thread thread, Throwable throwable) {
		logger.error("Uncaught Exception in thread "+ thread.getName(), throwable);
	}
270615
def handle_stderr(stream)
      @err_array = []
      # synchronize access to @err_array
      @semaphore = Mutex.new
      Thread.new do
        until (line = stream.gets).nil?
          line.strip!
          @semaphore.synchronize { @err_array << line if line.size > 3 }
        end
      end
    end
780632
public void process() throws InterruptedException {

		boolean alreadyInSync = Thread.currentThread() instanceof WebcamProcessor.ProcessorThread;

		if (alreadyInSync) {
			handle();
		} else {
			if (doSync) {
				if (processor == null) {
					throw new RuntimeException("Driver should be synchronized, but processor is null");
				}
				processor.process(this);
			} else {
				handle();
			}
		}
	}
1088251
final void end() {
    final Thread thread = this.threadRef;
    this.keepRunning.set(false);
    if (thread != null) {
     // thread.interrupt();
      try {
        thread.join();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }
    this.threadRef = null;
  }
397194
public void destroy()
	{
		mom.cleanUp();
		mThread.stop();
		si = null;
		mom = null;
		cache = null;
		mThread = null;
	}
97500
@Override
	protected void doStop() throws Exception {
		for (ThreadPoolExecutor pool: threadPools.values()){
			pool.shutdown();
		}

		for (ThreadPoolExecutor pool: threadPools.values()){
			shutdownAndAwaitTermination(pool, shutdownWaitSeconds);
		}

	}
1154461
private void remove(Thread t) {
        synchronized (this) {
            if (destroyed) {
                return;
            }
            for (int i = 0 ; i < nthreads ; i++) {
                if (threads[i] == t) {
                    System.arraycopy(threads, i + 1, threads, i, --nthreads - i);
                    // Zap dangling reference to the dead thread so that
                    // the garbage collector will collect it.
                    threads[nthreads] = null;
                    break;
                }
            }
        }
    }
380064
public final void stop() {
        if (this.thread != null) {
            try {
                if (this.thread != null) {
                    this.thread.interrupt();
                    synchronized (this.thread) {
                        this.thread.notifyAll();
                    }
                }
            } finally {
                this.thread = null;
            }
        }
    }
349605
void handleLoopException(Throwable t) {
        logger.warn("Unexpected exception in the selector loop.", t);

        // Prevent possible consecutive immediate failures that lead to
        // excessive CPU consumption.
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // Ignore.
        }
    }
286902
static final void eraseThreadLocals(Thread thread) {
    U.putObject(thread, THREADLOCALS, null);
    U.putObject(thread, INHERITABLETHREADLOCALS, null);
  }