问题描述
我需要将调用扩展到Tomcat,并建议在内部启动线程。有没有人需要这样做,如果有的话,他们提出了什么解决方案?
I need to scale calls into Tomcat and it's been suggested to launch threads internally. Has anyone needed to do this and, if so, what solutions did they come up with?
推荐答案
在一个内部创建自己的线程通常不鼓励使用应用程序服务器,因为服务器应该管理线程以获得更好的可伸缩性。如果容器对线程上下文中可用的内容做出假设,例如安全信息(例如,经过身份验证的主题),则也会遇到问题。如果你生成一个线程,然后使用该容器未知的服务器资源,通常会发生这种情况。
Creating your own threads inside an application server is generally discouraged because the server should manage threads for better scalability. You can also run into problems if the container makes assumptions about what's available in a thread context, such as security information (e.g., authenticated Subject). That typically happens if you spawn a thread and then use a server resource from that thread which is unknown to the container.
检查是否有办法获取容器来自Tomcat的托管线程。 WebLogic和WebSphere支持commonj.WorkManager,它允许您安排容器管理线程的工作。 Spring也可以使用commonj,但我不确定Tomcat上是否有这种支持。
Check to see if there is a way to get container managed threads from Tomcat. WebLogic and WebSphere support the commonj.WorkManager, which allows you to schedule work on container managed threads. Spring can also use commonj, but I'm not sure if that support is available on Tomcat.
这篇关于如何从Java EE中启动多个线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!