类hudson.util.DaemonThreadFactory源码实例Demo

下面列出了怎么用hudson.util.DaemonThreadFactory的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: git-client-plugin   文件: GitCommandsExecutor.java
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");
            }
        }
    }
}
 
源代码2 项目: ssh-steps-plugin   文件: SSHStepExecution.java
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;
}