EJB和线程 [英] EJB's and Threading

查看:276
本文介绍了EJB和线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的理解,从EJB中生成线程是非法的,因为它可能会干扰EJB的生命周期。但是,从JDK中使用预定义的Java类是非法的,内部生成并处理EJB内的Executor等线程,特别是MDB?

解决方案

线程和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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆