public ServicePool(ServerService next,
String name,
int threads) {
this.next = next;
final int keepAliveTime = (1000 * 60 * 5);
threadPool = new ThreadPoolExecutor(threads, threads, keepAliveTime, TimeUnit.MILLISECONDS, new LinkedBlockingQueue());
threadPool.setThreadFactory(new ThreadFactory() {
private volatile int id = 0;
public Thread newThread(Runnable arg0) {
Thread thread = new Thread(arg0, name + " " + getNextID());
return thread;
}
private int getNextID() {
return id++;
}
});
executor = threadPool;
SystemInstance.get().setComponent(ServicePool.class, this);
}
|