throw new IllegalArgumentException("defaultResurce must be > 0"); //$NON-NLS-1$
}
if (threadConfig == null) {
throw new IllegalArgumentException("threadConfig must not be null"); //$NON-NLS-1$
}
this.defaultExecutor = Executors.newFixedThreadPool(defaultResuorce, new ThreadFactory() {
private final AtomicInteger count = new AtomicInteger();
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r);
thread.setName(MessageFormat.format(
"ParallelJobScheduler-{0}",
String.valueOf(count.incrementAndGet())));
return thread;
}
});
HashMap<String, ExecutorService> map = new HashMap<String, ExecutorService>();
for (Map.Entry<String, Integer> entry : threadConfig.entrySet()) {
final String name = entry.getKey();
Integer value = entry.getValue();
if (value == null || value < 0) {
throw new IllegalArgumentException(MessageFormat.format(
"thread config must be > 0: key={0}, value={1}",
name,
value));
}
map.put(name, Executors.newFixedThreadPool(value, new ThreadFactory() {
private final AtomicInteger count = new AtomicInteger();
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r);
thread.setName(MessageFormat.format(