我正在编写一个分层的并发应用程序。我正在考虑提供每个图层使用不同的ForkJoinPool的选项(executor == null然后创建)。你知道它是否会引起问题吗?
我现在正在使用Executors中的ExecutorService。...在提交中,我正在使用Callables,它可以与每一层中的同一执行器一起正常工作
public AsyncTaskWorker(ExecutorService executor,
ScheduledExecutorService scheduled
, String resourceFile) {
this.resource = resourceFile;
this.executor = executor;
this.scheduled = scheduled;
}
/..inside a different layer./
public AsyncRuntimeExeTask(ExecutorService
executor,ScheduledExecutorService scheduled) {
this.executor = executor;
this.scheduledService = scheduled;
this.runtimeParam = new RuntimeParam();
}
/.../
public R submit() throws Exception {
try {
/* submits to executor */
}catch(Exception e){}
returns this.future;
}
一些资源竞争问题,解决了同步放置在正确零件中的问题