Example usage for java.lang ThreadGroup ThreadGroup

List of usage examples for java.lang ThreadGroup ThreadGroup

Introduction

In this page you can find the example usage for java.lang ThreadGroup ThreadGroup.

Prototype

public ThreadGroup(String name) 

Source Link

Document

Constructs a new thread group.

Usage

From source file:com.brienwheeler.lib.concurrent.NamedThreadFactory.java

@Required
public void setName(String name) {
    ValidationUtils.assertNotNull(name, "name cannot be null");

    ThreadGroup threadGroup = new ThreadGroup(name);
    if (!this.threadGroup.compareAndSet(null, threadGroup))
        throw new IllegalStateException("not allowed to rename " + getClass().getSimpleName());
}

From source file:com.dianping.resource.io.util.CustomizableThreadCreator.java

/**
 * Specify the name of the thread group that threads should be created in.
 * @see #setThreadGroup//w ww .j  a  v  a  2 s. c  om
 */
public void setThreadGroupName(String name) {
    this.threadGroup = new ThreadGroup(name);
}

From source file:cn.edu.zjnu.acm.judge.core.Judger.java

@PostConstruct
public void init() {
    final ThreadGroup group = new ThreadGroup("judge group");
    final AtomicInteger countet = new AtomicInteger();
    final ThreadFactory threadFactory = runnable -> new Thread(group, runnable,
            "judge thread " + countet.incrementAndGet());
    executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), threadFactory);
}

From source file:org.apache.axis2.transport.nhttp.ServerHandler.java

public ServerHandler(final ConfigurationContext cfgCtx, final HttpParams params) {
    super();/*from  www. j a va 2s .  com*/
    this.cfgCtx = cfgCtx;
    this.params = params;
    this.responseFactory = new DefaultHttpResponseFactory();
    this.httpProcessor = getHttpProcessor();
    this.connStrategy = new DefaultConnectionReuseStrategy();

    this.workerPool = new ThreadPoolExecutor(1, WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TimeUnit.SECONDS,
            new LinkedBlockingQueue(),
            new DefaultThreadFactory(new ThreadGroup("Server Worker thread group"), "HttpServerWorker"));
}

From source file:org.apache.axis2.transport.nhttp.ClientHandler.java

/**
 * Create an instance of this client connection handler using the Axis2 configuration
 * context and Http protocol parameters given
 * @param cfgCtx the Axis2 configuration context
 * @param params the Http protocol parameters to adhere to
 *///from w  w w .j  av  a  2  s  . c  om
public ClientHandler(final ConfigurationContext cfgCtx, final HttpParams params) {
    super();
    this.cfgCtx = cfgCtx;
    this.params = params;
    this.httpProcessor = getHttpProcessor();
    this.connStrategy = new DefaultConnectionReuseStrategy();

    workerPool = new ThreadPoolExecutor(1, WORKERS_MAX_THREADS, WORKER_KEEP_ALIVE, TimeUnit.SECONDS,
            new LinkedBlockingQueue(),
            new DefaultThreadFactory(new ThreadGroup("Client Worker thread group"), "HttpClientWorker"));
}

From source file:test.concurrency.TestApplicationScope.java

public void testApplicationScope() throws Exception {
    int threads = 50;
    int reps = 10;

    ThreadGroup group = new ThreadGroup("TestThreads");

    for (int i = 0; i < threads; i++) {
        TestRunnable tr = new TestRunnable(reps);
        Thread thread = new Thread(group, tr, "TestThread #" + i);
        thread.start();/*from   ww  w .j a  v  a2 s  .c o  m*/
    }

    while (group.activeCount() > 0 && error == null) {
        Thread.sleep(100);
    }

    if (error != null) {
        throw error;
    }
}

From source file:org.apache.axis2.transport.base.threads.NativeWorkerPool.java

public NativeWorkerPool(int core, int max, int keepAlive, int queueLength, int waterMark,
        String threadGroupName, String threadGroupId) {

    if (log.isDebugEnabled()) {
        log.debug("Using native util.concurrent package..");
    }//  w w  w.  j  a  v a 2 s  .  c  o  m

    blockingQueue = (queueLength == -1 ? new DefaultWaterMarkQueue<Runnable>(waterMark)
            : new DefaultWaterMarkQueue<Runnable>(waterMark, queueLength));

    executor = new WaterMarkExecutor(core, max, keepAlive, TimeUnit.SECONDS,
            (WaterMarkQueue<Runnable>) blockingQueue,
            new NativeThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
}

From source file:ThreadPool.java

/** Creates a new instance.
 * @param pMaxSize Maximum number of concurrent threads.
 * @param pName Thread group name.//from w w w  .  j  a  va2s .  com
 */
public ThreadPool(int pMaxSize, String pName) {
    maxSize = pMaxSize;
    threadGroup = new ThreadGroup(pName);
}

From source file:org.siddhiesb.transport.passthru.workerpool.NativeWorkerPool.java

public NativeWorkerPool(int core, int max, int keepAlive, int queueLength, int waterMark,
        String threadGroupName, String threadGroupId) {

    if (log.isDebugEnabled()) {
        log.debug("Using native util.concurrent package..");
    }//from w w  w. j  a v  a2 s . c  o m

    blockingQueue = (queueLength == -1 ? new DefaultWaterMarkQueue<Runnable>(waterMark)
            : new DefaultWaterMarkQueue<Runnable>(waterMark, queueLength));

    executor = new WaterMarkExecutor(core, max, keepAlive, TimeUnit.SECONDS,
            (org.siddhiesb.transport.passthru.workerpool.WaterMarkQueue<Runnable>) blockingQueue,
            new NativeThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
}

From source file:fish.payara.maven.plugins.micro.StartMojo.java

StartMojo() {
    threadGroup = new ThreadGroup(MICRO_THREAD_NAME);
}