Mercurial > hg > Database > Alice
view src/main/java/alice/codesegment/CodeSegmentManager.java @ 345:8f71c3e6f11d
Change directory structure Maven standard
author | sugi |
---|---|
date | Wed, 16 Apr 2014 18:26:07 +0900 |
parents | |
children | aefbe41fcf12 |
line wrap: on
line source
package alice.codesegment; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger; public class CodeSegmentManager { private static CodeSegmentManager instance = new CodeSegmentManager(); private ThreadPoolExecutor codeSegmentExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads Runtime.getRuntime().availableProcessors(), Integer.MAX_VALUE, // keepAliveTime TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); private Logger logger = Logger.getLogger(CodeSegmentManager.class); public static CodeSegmentManager get() { return instance; } public static void submit(CodeSegment cs) { CodeSegmentManager csManager = CodeSegmentManager.get(); csManager.codeSegmentExecutor.execute(cs); if (csManager.logger.isDebugEnabled()) { csManager.logger.debug(cs.getClass().getName()); } } }