java ee 启动,如何从Java EE中启动多个线程?

在考虑在Tomcat中扩展调用时,通常不建议在应用程序服务器内部创建线程,因为服务器应该负责线程管理以提高可扩展性。这样做可能会导致与容器对线程上下文的假设冲突,比如安全性信息(如认证主题)。你应该检查是否有从Tomcat获取容器管理线程的方法。WebLogic和WebSphere支持commonj.WorkManager,允许在容器管理的线程上调度工作,Spring也支持commonj,但不确定是否适用于Tomcat。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值