EJB和线程 [英] EJB's and Threading
问题描述
线程和EJB的最大问题是线程是容器大量使用的有限资源,线程错误导致线程池泄漏,可以有效地杀死整个JVM实例。
执行者应该更好的行为,但它仍然会耗尽一段线程一段时间;如果有人调整了容器以使用可用的线程,它也可能会立即失败。
总结是你将要走钢丝。
From what I understand it is illegal to spawn threads from within an EJB as it may potentially interfere with the EJB's lifecycle. However, is it illegal to use predefined Java classes from the JDK which internally spawn and handle threads such as Executor within an EJB, specifically an MDB?
The biggest issue with threads and EJBs is that threads are a limited resource heavily used by the container, and thread mistakes lead to thread pool leaks that can effectively kill the whole JVM instance.
Executor should be better behaved, but it's still going to use up a thread for some length of time; it also may just fail instantly if someone has tuned the container to use up the available threads.
Summary is that you're going to be tightrope walking.
这篇关于EJB和线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!