Search in sources :

Example 6 with TaskQueue

use of org.apache.tomcat.util.threads.TaskQueue in project tomcat by apache.

the class AbstractEndpoint method shutdownExecutor.

public void shutdownExecutor() {
    Executor executor = this.executor;
    if (executor != null && internalExecutor) {
        this.executor = null;
        if (executor instanceof ThreadPoolExecutor) {
            // this is our internal one, so we need to shut it down
            ThreadPoolExecutor tpe = (ThreadPoolExecutor) executor;
            tpe.shutdownNow();
            long timeout = getExecutorTerminationTimeoutMillis();
            if (timeout > 0) {
                try {
                    tpe.awaitTermination(timeout, TimeUnit.MILLISECONDS);
                } catch (InterruptedException e) {
                // Ignore
                }
                if (tpe.isTerminating()) {
                    getLog().warn(sm.getString("endpoint.warn.executorShutdown", getName()));
                }
            }
            TaskQueue queue = (TaskQueue) tpe.getQueue();
            queue.setParent(null);
        }
    }
}
Also used : ResizableExecutor(org.apache.tomcat.util.threads.ResizableExecutor) Executor(java.util.concurrent.Executor) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ThreadPoolExecutor(org.apache.tomcat.util.threads.ThreadPoolExecutor) TaskQueue(org.apache.tomcat.util.threads.TaskQueue) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ThreadPoolExecutor(org.apache.tomcat.util.threads.ThreadPoolExecutor)

Aggregations

TaskQueue (org.apache.tomcat.util.threads.TaskQueue)6 ThreadPoolExecutor (org.apache.tomcat.util.threads.ThreadPoolExecutor)6 TaskThreadFactory (org.apache.tomcat.util.threads.TaskThreadFactory)4 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)2 Executor (java.util.concurrent.Executor)1 ResizableExecutor (org.apache.tomcat.util.threads.ResizableExecutor)1