Tuesday, December 6, 2011

Using thread pool starting from java5

import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
* Processing jobs thread pool
*/
public class ProcessingJobExecutorService {
private static ProcessingJobExecutorService _instance =null;
private ExecutorService executorService;

private ProcessingJobExecutorService(){
executorService = new ScheduledThreadPoolExecutor(500);
}

public static ProcessingJobExecutorService getInstance(){
if(_instance==null){
_instance=new ProcessingJobExecutorService();
}
return _instance;
}
public void execute (Runnable r){
executorService.execute(r);

}

}

No comments:

Post a Comment