在Tomcat中打开新线程 [英] Open new thread in Tomcat
问题描述
我只是在问理论问题。
我有一个操作需要一段时间,这在一些Servlet doGet / doPost方法或者里面执行Spring MVC控制器。打开新的后台线程是一个好主意吗?
这不会导致性能问题吗?
I' have an operation which takes some period of time which is performed in some Servlet doGet/doPost method or inside of Spring MVC controller . is is good idea to open new background thread an perform it there? Won't it cause performance issue?
如果我在这种情况下使用jBoss JMS系统,我会得到一些好处吗?
Would I get some befits if I were using jBoss JMS system in this case?
推荐答案
没关系(Tomcat不是JavaEE容器)。既然你提到了Spring MVC,我建议使用 @Async
- 新的线程将由spring生成(这与等效的JavaEE注释非常相似)
It's OK (Tomcat is not a JavaEE container). Since you mention Spring MVC, I will suggest using @Async
on the method you want to execute - the new thread will be spawned by spring (which is very much the same as the equivalent JavaEE annotation)
这篇关于在Tomcat中打开新线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!