List of usage examples for com.google.common.util.concurrent ThreadFactoryBuilder ThreadFactoryBuilder
public ThreadFactoryBuilder()
From source file:com.google.firebase.internal.FirebaseScheduledExecutor.java
private static ThreadFactory decorateThreadFactory(ThreadFactory threadFactory, String name, Thread.UncaughtExceptionHandler handler) { checkArgument(!Strings.isNullOrEmpty(name)); ThreadFactoryBuilder builder = new ThreadFactoryBuilder().setThreadFactory(threadFactory) .setNameFormat(name).setDaemon(true); if (handler != null) { builder.setUncaughtExceptionHandler(handler); }// w ww .j a va 2s . co m return builder.build(); }
From source file:com.ziduye.utils.base.Threads.java
/** * ThreadFactory???"pool-x-thread-y"//from w w w . ja va 2 s . c om * * threaddump ?"mythread-%d"Guava */ public static ThreadFactory buildJobFactory(String nameFormat, boolean daemon) { return new ThreadFactoryBuilder().setNameFormat(nameFormat).setDaemon(daemon).build(); }
From source file:org.eclipse.che.workspace.infrastructure.kubernetes.util.KubernetesSharedPool.java
@Inject public KubernetesSharedPool() { final ThreadFactory factory = new ThreadFactoryBuilder().setNameFormat("KubernetesMachineSharedPool-%d") .setDaemon(true).build();/*from w w w . j ava 2s. c o m*/ this.executor = Executors.newCachedThreadPool(factory); }
From source file:com.facebook.nifty.core.NiftyTimer.java
public NiftyTimer(String prefix, long tickDuration, TimeUnit unit, int ticksPerWheel) { super(new ThreadFactoryBuilder().setNameFormat(prefix + "-timer-%s").setDaemon(true).build(), ThreadNameDeterminer.CURRENT, tickDuration, unit, ticksPerWheel); }
From source file:org.sonar.server.async.AsyncExecutionExecutorServiceImpl.java
private static ThreadPoolExecutor createDelegate() { ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(MAX_THREAD_COUNT, MAX_THREAD_COUNT, KEEP_ALIVE_TIME_IN_MINUTES, MINUTES, new LinkedBlockingQueue<>(UNLIMITED_QUEUE), new ThreadFactoryBuilder().setDaemon(false).setNameFormat("SQ_async-%d") .setUncaughtExceptionHandler( ((t, e) -> LOG.error("Thread " + t + " failed unexpectedly", e))) .build());/*from w w w. j ava 2 s . com*/ threadPoolExecutor.allowCoreThreadTimeOut(true); return threadPoolExecutor; }
From source file:org.apache.aurora.scheduler.base.AsyncUtil.java
/** * Creates a {@link ScheduledThreadPoolExecutor} that logs unhandled errors. * * @param poolSize Thread pool size./* w w w . j a va2 s .c om*/ * @param nameFormat Thread naming format. * @param logger Logger instance. * @return instance of {@link ScheduledThreadPoolExecutor} enabled to log unhandled exceptions. */ public static ScheduledThreadPoolExecutor loggingScheduledExecutor(int poolSize, String nameFormat, final Logger logger) { requireNonNull(nameFormat); return new ScheduledThreadPoolExecutor(poolSize, new ThreadFactoryBuilder().setDaemon(true).setNameFormat(nameFormat).build()) { @Override protected void afterExecute(Runnable runnable, Throwable throwable) { super.afterExecute(runnable, throwable); evaluateResult(runnable, throwable, logger); } }; }
From source file:org.eclipse.che.api.core.jsonrpc.impl.ServerSideRequestProcessor.java
@PostConstruct private void postConstruct() { ThreadFactory factory = new ThreadFactoryBuilder() .setUncaughtExceptionHandler(LoggingUncaughtExceptionHandler.getInstance()) .setNameFormat(ServerSideRequestProcessor.class.getSimpleName()).setDaemon(true).build(); executorService = newCachedThreadPool(factory); }
From source file:com.hpcloud.util.concurrent.ThreadPools.java
public static InstrumentedThreadPoolExecutor newInstrumentedCachedThreadPool(MetricRegistry metricRegistry, String name, int corePoolSize, int maxPoolSize) { return new InstrumentedThreadPoolExecutor(metricRegistry, name, corePoolSize, maxPoolSize, 60l, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactoryBuilder().setNameFormat(name + "-%s").build()); }
From source file:com.google.gerrit.server.patch.DiffExecutorModule.java
@Provides @Singleton/*from w w w .j a va 2 s . c om*/ @DiffExecutor public ExecutorService createDiffExecutor() { return Executors .newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("Diff-%d").setDaemon(true).build()); }
From source file:co.paralleluniverse.fibers.dropwizard.FiberDBIFactory.java
public FiberDBIFactory(final int threadsNum) { this(Executors.newFixedThreadPool(threadsNum, new ThreadFactoryBuilder().setNameFormat("jdbc-worker-%d").setDaemon(true).build())); }