下面列出了怎么用hudson.util.DaemonThreadFactory的API类实例代码及写法,或者点击链接到github查看源代码。
public <T> void invokeAll(Collection<Callable<T>> commands) throws GitException, InterruptedException {
ExecutorService executorService = null;
try {
if (threads == 1) {
executorService = MoreExecutors.sameThreadExecutor();
} else {
ThreadFactory threadFactory = new ExceptionCatchingThreadFactory(new NamingThreadFactory(new DaemonThreadFactory(), GitCommandsExecutor.class.getSimpleName()));
executorService = Executors.newFixedThreadPool(threads, threadFactory);
}
invokeAll(executorService, commands);
} finally {
if (executorService != null) {
executorService.shutdownNow();
if (!executorService.awaitTermination(10, TimeUnit.SECONDS)) {
listener.getLogger().println("[WARNING] Threads did not terminate properly");
}
}
}
}
static synchronized ExecutorService getExecutorService() {
if (executorService == null) {
executorService = Executors.newCachedThreadPool(
new NamingThreadFactory(new ClassLoaderSanityThreadFactory(new DaemonThreadFactory()),
"org.jenkinsci.plugins.ssh.util.SSHStepExecution"));
}
return executorService;
}
/**
* Workaround visibility restriction of {@code org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution#getExecutorService()}
*/
static synchronized ExecutorService getExecutorService() {
if (executorService == null) {
executorService = Executors.newCachedThreadPool(new NamingThreadFactory(new DaemonThreadFactory(), "org.jenkinsci.plugins.pipeline.maven.fix.jenkins49337.GeneralNonBlockingStepExecution"));
}
return executorService;
}