Thread -- Request

Servlet容器应该绝大部分(有可能全部)是Thread per Request,每个请求一个线程。此外有Thread per Connection,应该不是用于Servlet容器。请见

How are Threads allocated to handle Servlet request?

另外,大部分容器使用线程池管理线程。

 

上面链接中也提到在Java EE环境下不要创建太多自己的线程,要向容器申请线程,参见评论中的链接:

Why is spawning threads in Java EE container discouraged?

 

如果在线程中使用threadlocal,也许需要考虑清理threadlocal,请见:

How to clean up threadlocals

ThreadLocal Variables and Thread Pools – It Can Go Wrong

posted @ 2017-02-08 22:36  raindream  阅读(330)  评论(0编辑  收藏  举报