EJB 中的线程生成库
Thread spawning libraries in EJB
是否允许在生成和管理线程的 EJB 中使用库?
我用 class 编写了一个 JavaSE 库,如下所示:
public class LibraryClass {
public void longRunningMethod() {
ExecutorService service = Executors.newFixedThreadPool(10);
//schedule tasks
service.shutdown();
try {
service.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
EJB 示例:
@Stateless
class Bean {
public void beanMethod() {
LibraryClass libraryClass = new LibraryClass();
libraryClass.longRunningMethod();
}
}
在 EJB 中使用这样的东西可以吗?
规范指出 "The enterprise bean must not attempt to manage threads",如果线程在 EJB 之外进行管理,这是否仍然适用,甚至可能不受开发人员控制(例如,在使用第 3 方库时)?
是否允许在生成和管理线程的 EJB 中使用库?
我用 class 编写了一个 JavaSE 库,如下所示:
public class LibraryClass {
public void longRunningMethod() {
ExecutorService service = Executors.newFixedThreadPool(10);
//schedule tasks
service.shutdown();
try {
service.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
EJB 示例:
@Stateless
class Bean {
public void beanMethod() {
LibraryClass libraryClass = new LibraryClass();
libraryClass.longRunningMethod();
}
}
在 EJB 中使用这样的东西可以吗?
规范指出 "The enterprise bean must not attempt to manage threads",如果线程在 EJB 之外进行管理,这是否仍然适用,甚至可能不受开发人员控制(例如,在使用第 3 方库时)?