/** * Create a {@link ComputationExecutor} with a given maximal number of * threads and the the given name which is used to identify threads * * @param threadCount * @param name */ public ComputationExecutor(int threadCount, String name) { this(threadCount, new ComputationThreadGroup(name)); }
@Override public Thread newThread(Runnable r) { Thread result = new Thread(threadGroup, r, threadGroup.getName() + "-thread-" + threadGroup.getNextThreadId()); /* * Worker threads don't do any sort of IO and shouldn't * require any clean-up. So they can be safely abandoned * when JVM exits. */ result.setDaemon(true); return result; } });
/** * Interrupting all threads of this executor (used to wake up waiting * threads if something needs to be notified) */ public void interrupt() { checkException(); threadGroup.interrupt(); }