I've never worked with Concurrency library before.
public class QueueExecutor {
static final int defaultCorePoolSize = 5;
static final int defaultMaximumPoolSize = 10;
static final long defaultKeepAliveTime = 10;
static final TimeUnit defaultTimeUnit = TimeUnit.MINUTES;
static final BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>();
private static ThreadPoolExecutor instance;
private QueueExecutor() {
instance = new ThreadPoolExecutor(defaultCorePoolSize, defaultMaximumPoolSize, defaultKeepAliveTime, defaultTimeUnit, workQueue);
}
public static ThreadPoolExecutor getInstance() {
if (instance == null) {
QueueExecutor();
}
return instance;
}
public static add(Runnable runnable){
} instance.execute(runnable);
}
My question is the following, If this object is running inside JBoss application container, should I synchronize add
and getInstance
functions and why? I think that these ThreadPoolExecutor
is already syncronized.