Skip to content

Instantly share code, notes, and snippets.

@mfilipelino
Created August 19, 2015 00:12
Show Gist options
  • Save mfilipelino/c06ebaf5e36a5b2dfb35 to your computer and use it in GitHub Desktop.
Save mfilipelino/c06ebaf5e36a5b2dfb35 to your computer and use it in GitHub Desktop.
#java #thread #concurrent #pool #threadpool #Executors #ExecutorService
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ContainerThreadPool {
private static ContainerThreadPool contairnerThreadPoll;
public static ContainerThreadPool getInstance() {
if( contairnerThreadPoll == null ) {
contairnerThreadPoll = new ContainerThreadPool();
}
return contairnerThreadPoll;
}
public ExecutorService threadPool;
private ContainerThreadPool() {
this.threadPool = Executors.newCachedThreadPool();
}
public void execute(Runnable r) {
threadPool.execute(r);
}
public void fecharthreads() {
threadPool.shutdown();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment