Example usage for com.google.common.util.concurrent ThreadFactoryBuilder setDaemon

List of usage examples for com.google.common.util.concurrent ThreadFactoryBuilder setDaemon

Introduction

In this page you can find the example usage for com.google.common.util.concurrent ThreadFactoryBuilder setDaemon.

Prototype

public ThreadFactoryBuilder setDaemon(boolean daemon) 

Source Link

Document

Sets daemon or not for new threads created with this ThreadFactory.

Usage

From source file:org.apache.hadoop.hbase.replication.ReplicationTableBase.java

/**
 * Sets up the thread pool executor used to build the Replication Table in the background
 * @return the configured executor// w  w w .  j a v  a  2  s  .c  o m
 */
private Executor setUpExecutor() {
    ThreadPoolExecutor tempExecutor = new ThreadPoolExecutor(NUM_INITIALIZE_WORKERS, NUM_INITIALIZE_WORKERS,
            100, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
    ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();
    tfb.setNameFormat("ReplicationTableExecutor-%d");
    tfb.setDaemon(true);
    tempExecutor.setThreadFactory(tfb.build());
    return tempExecutor;
}

From source file:org.apache.hadoop.hbase.thrift.ThriftServerRunner.java

ExecutorService createExecutor(BlockingQueue<Runnable> callQueue, int workerThreads) {
    ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();
    tfb.setDaemon(true);
    tfb.setNameFormat("thrift-worker-%d");
    return new ThreadPoolExecutor(workerThreads, workerThreads, Long.MAX_VALUE, TimeUnit.SECONDS, callQueue,
            tfb.build());//from w w w  . j  av a2  s. c  o m
}