Java Code Examples for org.apache.tomcat.util.threads.ThreadPoolExecutor#getQueue()

The following examples show how to use org.apache.tomcat.util.threads.ThreadPoolExecutor#getQueue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractEndpoint.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * 关闭线程池
 */
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);
        }
    }
}
 
Example 2
Source File: AbstractEndpoint.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
public void shutdownExecutor() {
    if ( executor!=null && internalExecutor ) {
        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);
        }
        executor = null;
    }
}
 
Example 3
Source File: AbstractEndpoint.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
public void shutdownExecutor() {
    if ( executor!=null && internalExecutor ) {
        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);
        }
        executor = null;
    }
}