在Tomcat中打开新线程 [英] Open new thread in Tomcat

查看:198
本文介绍了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆