}
protected ThreadPoolExecutor createDefaultExecutor(final String name,
final int priority,
final boolean daemon) {
ThreadPoolExecutor rc = new ThreadPoolExecutor(corePoolSize, maxPoolSize, 10,
TimeUnit.SECONDS, new SynchronousQueue(),
new edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory() {
public Thread newThread(
final Runnable runnable) {
// do the following section as privileged
// so that it will work even when java2 security
// has been enabled
Thread returnThread = null;
try {
returnThread =
(Thread) AccessController
.doPrivileged(
new PrivilegedExceptionAction() {
public Object run() {
Thread newThread =
new Thread(
runnable,
name);
newThread
.setDaemon(
daemon);
newThread
.setPriority(
priority);
return newThread;
}
}
);
}
catch (PrivilegedActionException e) {
// note: inner class can't have its own static log variable
if (log.isDebugEnabled()) {
log.debug(
"ThreadPoolExecutor.newThread(): Exception from AccessController [" +
e.getClass()
.getName() +
"] for [" +
e.getMessage() +
"]", e);
}
}
return returnThread;
}
});
rc.allowCoreThreadTimeOut(true);
return rc;
}