后台线程 Tomcat Struts2
我有一个使用 struts2 和 tomcat 6 作为服务器的 Web 应用程序。我必须执行 jar 文件中的一些逻辑,但这需要一些时间才能完成。这就是为什么我想在单独的线程中将数据从执行方法发送到该类,因为如果我在执行方法中使用该类,我必须等到所有逻辑完成。
我尝试过使用 execAndWait 拦截器,逻辑位于单独的线程中,但在该线程完成之前我无法在应用程序中执行任何操作(因为 execAndWait 的每个会话)。
我想知道是否有另一种方法可以在另一个线程中处理逻辑?
提前致谢
I have a web application using struts2 and tomcat 6 as a server. I have to do some logic that is in a jar file, but this take some time to finish. That's why I want to send the data from the execute method to that class in a separate thread, because if I use the class in the execute method I have to wait until all the logic is finished.
I've tried with execAndWait interceptor, the logic is in a separate thread, but I can't do anything in my application until that thread is finished (because of the per-session of execAndWait).
I want to know if there's another way to process the logic in another thread?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用添加的Executor Framework在Java 5中。
You can use the Executor Framework that was added in Java 5.
如果您将 Struts2 与 Spring 一起使用,则可以使用 Spring TaskExecutor。
http://static.springsource.org/spring/docs/2.0 .x/reference/scheduling.html
If you're using Struts2 with Spring you could use the Spring TaskExecutor.
http://static.springsource.org/spring/docs/2.0.x/reference/scheduling.html