hudson.util.NamingThreadFactory Java Examples

The following examples show how to use hudson.util.NamingThreadFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitCommandsExecutor.java    From git-client-plugin with MIT License 6 votes vote down vote up
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");
            }
        }
    }
}
 
Example #2
Source File: SSHStepExecution.java    From ssh-steps-plugin with Apache License 2.0 5 votes vote down vote up
static synchronized ExecutorService getExecutorService() {
  if (executorService == null) {
    executorService = Executors.newCachedThreadPool(
        new NamingThreadFactory(new ClassLoaderSanityThreadFactory(new DaemonThreadFactory()),
            "org.jenkinsci.plugins.ssh.util.SSHStepExecution"));
  }
  return executorService;
}
 
Example #3
Source File: GeneralNonBlockingStepExecutionUtils.java    From pipeline-maven-plugin with MIT License 5 votes vote down vote up
/**
 * 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;
}