有状态会话bean多线程访问 [英] Stateful session bean multi-threaded access

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

问题描述

EJB 3.2规范说明如下:

The EJB 3.2 spec says the following:


默认情况下,客户端允许对有状态会话对象进行并发调用, container是
需要序列化这样的并发请求。注意,容器从不允许多线程
访问实际的有状态会话bean实例。

By default, clients are allowed to make concurrent calls to a stateful session object and the container is required to serialize such concurrent requests. Note that the container never permits multi-threaded access to the actual stateful session bean instance.

多线程访问看起来是等效的。那么,当禁止多个线程时,如何可以并发调用有状态的EJB呢?

To me concurrent access and multi-threaded access seem equivalent. So how is it possible to make concurrent calls to a stateful EJB while multiple threads are prohibited?

推荐答案

您是对的:并发呼叫只能使用多个线程。所以,当谈到并发性时,涉及到多个线程。

You are right: Concurrent calls can only be made with multiple threads. So, when speaking about concurrency, there are multiple threads involved.

规范清楚地说,容器不允许同时访问一个有状态会话bean实例。如果有并发调用(来自多个线程),容器必须将它们序列化。

The spec clearly says that the container is not allowed to concurrently access one stateful session bean instance. If there are concurrent calls (from multiple threads), the container must serialize them.

注意,当然可以有多个实例的有状态会话bean,

Note, that there could of course be several instances of that stateful session bean, which of course can be accessed by several clients.

另外,这似乎让你感到困惑 - 规范说,客户端允许进行并发调用,但容器必须将它们序列化。

Additionally - and that seems to confuse you - the spec say that a client (not the container) is allowed to make concurrent calls, but the container then must serialize them.

这篇关于有状态会话bean多线程访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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