executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), 60, TimeUnit.SECONDS,taskqueue, tf);
taskqueue.setParent( (ThreadPoolExecutor) executor);
}
- } else {
+ } else if ( executor != null ) {//avoid two thread pools being created
workers = new WorkerStack(maxThreads);
}
}
public boolean offer(Runnable o) {
- if ( parent != null && parent.getPoolSize()<parent.getMaximumPoolSize() ) return false;
+ if ( parent != null && parent.getPoolSize()<parent.getMaximumPoolSize() ) return false;//force creation of new threads
else return super.offer(o);
}
}
public Thread newThread(Runnable r) {
Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement());
- t.setDaemon(true);
+ t.setDaemon(daemon);
t.setPriority(getThreadPriority());
return t;
}