ThreadPollService.java
921 Bytes
package com.diligrp.assistant.shared.service;
import com.diligrp.assistant.shared.Constants;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public final class ThreadPollService {
private static volatile ExecutorService threadPoll;
private ThreadPollService() {
}
public static ExecutorService getInstance() {
if (threadPoll == null) {
synchronized (ThreadPollService.class) {
if (threadPoll == null) {
threadPoll = new ThreadPoolExecutor(Constants.CORE_POOL_SIZE, Constants.MAX_POOL_SIZE,
1, TimeUnit.MINUTES, new LinkedBlockingQueue(1000),
new ThreadPoolExecutor.CallerRunsPolicy());
}
}
}
return threadPoll;
}
}