Java app服务器能够销毁线程吗?如果有,怎么样? [英] Are java app servers able to destroy threads? If yes, how?
问题描述
销毁线程在Java中已弃用(并未根据javadoc实现),并且中断它只是在线程预期退出时的建议,但可能不会这样做。 (不提供任何方法来杀死J VM 中的线程是一个令人不安的设计,但我的问题与设计无关。)
Destroying threads is deprecated in Java (and not implemented according to javadoc), and interrupting it is only a suggestion which upon the thread is expected to quit, but might not do so. (Not to provide any way to kill a thread inside the JVM is a disturbing design, but my question is not design related.)
Java应用程序服务器如何卸载应用程序?他们能以某种方式破坏正在卸载的应用程序的线程吗?如果有,怎么样?如果不是,那么带有无限循环的部署应用程序的单个线程可能会导致整个应用服务器无法进行干预?
How do Java application servers unload applications? Are they able somehow to destroy the threads of an application being unloaded? If yes, how? If no, then a single thread of a deployed app with an infinite-loop could bring down an entire app server without any possibility to intervene?
抱歉我不是为此编写测试用例,但我想知道那里到底发生了什么。
Sorry that I'm not writing test cases for this, but I would like to know what is really going on there.
推荐答案
你不被允许在ejb服务器中创建自己的线程。
You're not allowed to create a thread of your own inside an ejb server.
在Web容器(例如tomcat)中生成线程并不常见,尽管你应该仔细考虑关于这样做 - 并确保管理这些线程的生命周期。
It's not that uncommon to spawn threads in a web container(such as e.g. tomcat) , though you should really think carefully about doing that - and be sure to manage the lifecycle of those threads.
这篇关于Java app服务器能够销毁线程吗?如果有,怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!