tomcat8的后台线程
所属分类 tomcat
浏览量 917
嵌入式启动
tomcat8 嵌入式 servlet 实例
dyyx.Main at localhost:50351
Thread [main] (Running)
Daemon Thread [NioBlockingSelector.BlockPoller-1] (Running)
Daemon Thread [ContainerBackgroundProcessor[StandardEngine[Tomcat]]] (Running)
Daemon Thread [http-nio-8086-ClientPoller-0] (Running)
Daemon Thread [http-nio-8086-ClientPoller-1] (Running)
Daemon Thread [http-nio-8086-Acceptor-0] (Running)
Daemon Thread [http-nio-8086-AsyncTimeout] (Running)
Daemon Thread [http-nio-8086-exec-1] (Running)
Daemon Thread [http-nio-8086-exec-2] (Running)
Daemon Thread [http-nio-8086-exec-3] (Running)
ContainerBackgroundProcessor线程
Private thread class to invoke the backgroundProcess method of this container and its children after a fixed delay.
BlockPoller 处理阻塞的读写操作
Daemon Thread [http-nio-8086-exec-N] 工作线程
Acceptor accept线程 接受新连接
ClientPoller IO读写线程
The background thread that adds sockets to the Poller,
checks the poller for triggered events
and hands the associated socket off to an appropriate processor as events occur.
AsyncTimeout
The background thread that checks async requests and fires the timeout if there has been no activity.
Daemon Thread [NioBlockingSelector.BlockPoller-1] (Running)
org.apache.tomcat.util.net.NioBlockingSelector.BlockPoller
public void open(Selector selector) {
sharedSelector = selector;
poller = new BlockPoller();
poller.selector = sharedSelector;
poller.setDaemon(true);
poller.setName("NioBlockingSelector.BlockPoller-"+(++threadCounter));
poller.start();
}
Daemon Thread [ContainerBackgroundProcessor[StandardEngine[Tomcat]]] (Running)
org.apache.catalina.core.ContainerBase.threadStart()
String threadName = "ContainerBackgroundProcessor[" + toString() + "]";
thread = new Thread(new ContainerBackgroundProcessor(), threadName);
thread.setDaemon(true);
thread.start();
Daemon Thread [http-nio-8086-ClientPoller-0] (Running)
NioEndpoint.startInternal()
// Start poller threads
pollers = new Poller[getPollerThreadCount()];
for (int i=0; i < pollers.length; i++) {
pollers[i] = new Poller();
Thread pollerThread = new Thread(pollers[i], getName() + "-ClientPoller-"+i);
pollerThread.setPriority(threadPriority);
pollerThread.setDaemon(true);
pollerThread.start();
}
Daemon Thread [http-nio-8086-Acceptor-0] (Running)
org.apache.tomcat.util.net.Nio2Endpoint.Acceptor
org.apache.tomcat.util.net.AbstractEndpoint.startAcceptorThreads()
protected final void startAcceptorThreads() {
int count = getAcceptorThreadCount();
acceptors = new Acceptor[count];
for (int i = 0; i < count; i++) {
acceptors[i] = createAcceptor();
String threadName = getName() + "-Acceptor-" + i;
acceptors[i].setThreadName(threadName);
Thread t = new Thread(acceptors[i], threadName);
t.setPriority(getAcceptorThreadPriority());
t.setDaemon(getDaemon());
t.start();
}
}
Daemon Thread [http-nio-8086-AsyncTimeout] (Running)
org.apache.coyote.AbstractProtocol.AsyncTimeout
org.apache.coyote.AbstractProtocol.start()
asyncTimeout = new AsyncTimeout();
Thread timeoutThread = new Thread(asyncTimeout, getNameInternal() + "-AsyncTimeout");
timeoutThread.setPriority(endpoint.getThreadPriority());
timeoutThread.setDaemon(true);
timeoutThread.start();
Daemon Thread [http-nio-8086-exec-2] (Suspended (breakpoint at line 20 in HelloServlet))
owns: NioChannel (id=69)
HelloServlet.doPost(HttpServletRequest, HttpServletResponse) line: 20
HelloServlet.doGet(HttpServletRequest, HttpServletResponse) line: 15
HelloServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 622
HelloServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 729
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 230
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 165
StandardWrapperValve.invoke(Request, Response) line: 198
StandardContextValve.invoke(Request, Response) line: 108
NonLoginAuthenticator(AuthenticatorBase).invoke(Request, Response) line: 522
StandardHostValve.invoke(Request, Response) line: 140
ErrorReportValve.invoke(Request, Response) line: 79
StandardEngineValve.invoke(Request, Response) line: 87
CoyoteAdapter.service(Request, Response) line: 343
Http11Processor.service(SocketWrapperBase>) line: 1096
Http11Processor(AbstractProcessorLight).process(SocketWrapperBase>, SocketEvent) line: 66
AbstractProtocol$ConnectionHandler.process(SocketWrapperBase, SocketEvent) line: 760
NioEndpoint$SocketProcessor.run() line: 1480
ThreadPoolExecutor(ThreadPoolExecutor).runWorker(ThreadPoolExecutor$Worker) line: 1142
ThreadPoolExecutor$Worker.run() line: 617
TaskThread$WrappingRunnable.run() line: 61
工作线程池
org.apache.tomcat.util.threads.ThreadPoolExecutor
org.apache.tomcat.util.net.AbstractEndpoint.createExecutor()
public void createExecutor() {
internalExecutor = true;
TaskQueue taskqueue = new TaskQueue();
TaskThreadFactory tf = new TaskThreadFactory(getName() + "-exec-", daemon, getThreadPriority());
executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), 60, TimeUnit.SECONDS,taskqueue, tf);
taskqueue.setParent( (ThreadPoolExecutor) executor);
}
上一篇
下一篇
tomcat8 嵌入式 servlet 实例
tomcat8 连接器
Tomcat NIO 处理机制
tomcat请求处理过程
tomcat nio 读写关键代码
springboot2动态设置日志级别