我在 JSP 中有一个 session bean,在该 bean 中我启动了一个 hibernate 10 秒并再次执行的线程。我面临的问题是,注销后该线程仍然继续运行。
有人可以帮忙如何阻止它运行吗?
最佳答案
根据EJB specification ,从 EJB 启动线程是非法的。比照。第 21.2.2 节(第 593 页):
"The enterprise bean must not attempt to manage threads. The enterprise bean must not attempt to start, stop, suspend, or resume a thread, or to change a thread’s priority or name. The enterprise bean must not attempt to manage thread groups."
可能有使用 EJB 的不同解决方案,或者您可能需要使用不同的框架。这取决于您到底想要实现什么目标。
关于java - java bean 中的线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14253488/