gpt4 book ai didi

multithreading - 不同的线程可以访问无状态EJB特定实例的不同方法吗?

转载 作者:行者123 更新时间:2023-12-03 12:52:36 26 4
gpt4 key购买 nike

@Stateless
public class MyBean1 {

pulic void method1() {
//method implementation
}

pulic void method2() {
//method implementation
}
}

考虑 MyBean1的特定实例。然后我们知道 method1()method2()不能同时被多个线程访问。但是,当一个线程正在访问 method1()时,另一个线程可以访问 method2()吗?

最佳答案

我认为ejb 3.1规范的secion 4.3.14给出了答案。

4.3.14 Serializing Session Bean Methods
The following requirements apply to Stateless and Stateful session beans. See Section 4.8.5 for Singleton session bean concurrency requirements.

The container serializes calls to each stateful and stateless session bean instance. Most containers will support many instances of a session bean executing concurrently; however, each instance sees only a serialized sequence of method calls. Therefore, a stateful or stateless session bean does not have to be coded as reentrant.

The container must serialize all the container-invoked callbacks (that is, the business method interceptor methods, lifecycle callback interceptor methods, timeout callback methods, beforeCompletion, and so on), and it must serialize these callbacks with the client-invoked business method calls.

....



据我了解EJB规范,如果要对并发(bean管理,容器管理)进行细粒度控制,则应使用Singletons。

关于multithreading - 不同的线程可以访问无状态EJB特定实例的不同方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18008649/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com