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.)
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.
You're not allowed to create a thread of your own inside an ejb server.
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.