在基于 Websphere 的应用程序中实现并发

Implementing concurrency in Websphere based application

我们正在开发部署在 Websphere Web 服务器上的 Java EE Web 应用程序。目前有并发执行加速响应时间的需求。那么在以下选择中,哪个以及为什么会是更好的选择?

  1. 使用ExecutorService
  2. 使用Managed Executor Service (以上两种方法的基本用法和实现区别是什么)
  3. 还有其他选择吗?

ManagedExecutorService 的 javadoc 非常清楚地说明了区别:

A ManagedExecutorService extends the Java™ SE ExecutorService to provide methods for submitting tasks for execution in a Java™ EE environment. Implementations of the ManagedExecutorService are provided by a Java™ EE Product Provider. Application Component Providers use the Java Naming and Directory Interface™ (JNDI) to look-up instances of one or more ManagedExecutorService objects using resource environment references. ManagedExecutorService instances can also be injected into application components through the use of the Resource annotation.

您应该只使用规范定义的 EE 并发实用程序(包括 ManagedExecutor)。

https://www.ibm.com/support/knowledgecenter/en/SSAW57_9.0.0/com.ibm.websphere.nd.multiplatform.doc/asyncbns/concepts/casb_concurrency.html