Created
August 19, 2015 00:12
-
-
Save mfilipelino/c06ebaf5e36a5b2dfb35 to your computer and use it in GitHub Desktop.
#java #thread #concurrent #pool #threadpool #Executors #ExecutorService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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