MCPcopy Create free account
hub / github.com/annmuor/jnode / ThreadPool

Class ThreadPool

jnode-core/src/jnode/main/threads/ThreadPool.java:29–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27import jnode.logger.Logger;
28
29public class ThreadPool {
30 private static ThreadPool self;
31 private static final Logger logger = Logger.getLogger(ThreadPool.class);
32 private ThreadPoolExecutor executor;
33
34 public ThreadPool(int numThreads) {
35 executor = new ThreadPoolExecutor(numThreads, (int) (numThreads * 1.5),
36 30, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
37
38 logger.l3("Thread pool (" + numThreads + " threads) started");
39 self = this;
40 }
41
42 public static void execute(Runnable r) {
43 if (self != null) {
44 self.executor.execute(r);
45 }
46 }
47
48 public static boolean isBusy() {
49 if (self != null) {
50 return self.executor.getQueue().size() > self.executor
51 .getMaximumPoolSize();
52 }
53 return true;
54 }
55}

Callers

nothing calls this directly

Calls 1

getLoggerMethod · 0.95

Tested by

no test coverage detected