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:org.apache.hadoop.hdfs.server.namenode.Namenode2Agent.java

/**
 * Namenode Monitoring Agent .//from   w  w  w  .ja v  a2  s  .  c om
 *
 * @param args Apache Hadoop Namenode, Configuration
 * @throws RuntimeException    
 */
public static void start(Object nn, Object[] args) {
    Namenode2Agent.namenode = (NameNode) nn;
    Namenode2Agent.configuration = (Configuration) args[0];

    if (!isInitialized) {
        isInitialized = true;

        Thread t = new Thread(new ThreadGroup("Flamingo"), new Runnable() {
            @Override
            public void run() {
                try {
                    startup();
                    context = new ClassPathXmlApplicationContext("applicationContext-namenode2.xml");

                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                    throw new RuntimeException("Flamingo :: Cannot initialized.", e);
                }
            }
        }, "Namenode 2 Agent");
        t.start();
    }
}

From source file:org.bml.util.alert.AlertControl.java

public AlertControl() {
    super(new ThreadGroup("AlertControl"), CLASS_NAME);
}

From source file:org.apache.synapse.transport.nhttp.util.NativeWorkerPool.java

public NativeWorkerPool(int core, int max, int keepAlive, int queueLength, String threadGroupName,
        String threadGroupId) {/*from  w w  w . j  a  va 2s  .c om*/

    if (log.isDebugEnabled()) {
        log.debug("Using native util.concurrent package..");
    }
    executor = new ThreadPoolExecutor(core, max, keepAlive, TimeUnit.SECONDS,
            queueLength == -1 ? new LinkedBlockingQueue() : new LinkedBlockingQueue(queueLength),
            new BackportThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
}

From source file:org.apache.axis2.transport.nhttp.util.BackportWorkerPool.java

public BackportWorkerPool(int core, int max, int keepAlive, int queueLength, String threadGroupName,
        String threadGroupId) {// w  w  w  .  j  av a  2  s. c om

    executor = new ThreadPoolExecutor(core, max, keepAlive, TimeUnit.SECONDS,
            queueLength == -1 ? new LinkedBlockingQueue() : new LinkedBlockingQueue(queueLength),
            new BackportThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
}

From source file:org.apache.synapse.transport.nhttp.util.BackportWorkerPool.java

public BackportWorkerPool(int core, int max, int keepAlive, int queueLength, String threadGroupName,
        String threadGroupId) {//from   w  w w  .  java  2s.c om

    if (log.isDebugEnabled()) {
        log.debug("Using backport of the util.concurrent package..");
    }
    executor = new ThreadPoolExecutor(core, max, keepAlive, TimeUnit.SECONDS,
            queueLength == -1 ? new LinkedBlockingQueue() : new LinkedBlockingQueue(queueLength),
            new BackportThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
}

From source file:org.apache.axis2.jaxws.utility.JAXWSThreadFactory.java

public Thread newThread(final Runnable r) {
    if (threadGroup == null) {
        try {/*from   w w w.  j  a  v a2  s . c  o  m*/
            threadGroup = (ThreadGroup) AccessController.doPrivileged(new PrivilegedExceptionAction() {
                public Object run() {
                    return new ThreadGroup("JAX-WS Default Executor Group " + groupNumber++);
                }
            });
        } catch (PrivilegedActionException e) {
            if (log.isDebugEnabled()) {
                log.debug("Exception thrown from AccessController: " + e);
            }
            throw ExceptionFactory.makeWebServiceException(e.getException());
        }
    }

    threadNumber++;
    Thread returnThread = null;
    try {
        returnThread = (Thread) AccessController.doPrivileged(new PrivilegedExceptionAction() {
            public Object run() {
                Thread newThread = new Thread(threadGroup, r);
                newThread.setDaemon(true);
                return newThread;
            }
        });
    } catch (PrivilegedActionException e) {
        if (log.isDebugEnabled()) {
            log.debug("Exception thrown from AccessController: " + e);
        }
        throw ExceptionFactory.makeWebServiceException(e.getException());
    }

    return returnThread;
}

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

public NativeWorkerPool(int core, int max, int keepAlive, int queueLength, String threadGroupName,
        String threadGroupId) {//from  w w w. jav a 2  s  .  c o m

    if (log.isDebugEnabled()) {
        log.debug("Using native util.concurrent package..");
    }
    blockingQueue = (queueLength == -1 ? new LinkedBlockingQueue<Runnable>()
            : new LinkedBlockingQueue<Runnable>(queueLength));
    executor = new Axis2ThreadPoolExecutor(core, max, keepAlive, TimeUnit.SECONDS, blockingQueue,
            new NativeThreadFactory(new ThreadGroup(threadGroupName), threadGroupId));
}

From source file:pdl.operator.service.JobExecutor.java

public JobExecutor(JobDetail currJob, CctoolsOperator operator) {
    this(new ThreadGroup("worker"), currJob, operator, new JobManager());
}

From source file:WorkThreadPool.java

/**
 * Creates a new work thread pool with the specified number of work threads.
 * /*from  ww  w. jav a 2s. com*/
 * @param name
 *          The thread name prefix
 * @param count
 *          The number of work threads
 */
public WorkThreadPool(String name, int count) {
    listenerList = new EventListenerList();

    if (count != 0) {
        threadGroup = new ThreadGroup(name);
        threads = new WorkThread[count];
        for (int i = 0; i < threads.length; i++) {
            threads[i] = new WorkThread(this, threadGroup, name + " #" + (i + 1));
        }
    }

}

From source file:org.commonjava.indy.ftest.core.fixture.ThreadDumper.java

public static TestRule timeoutRule(int timeout, TimeUnit units) {
    return (base, description) -> new Statement() {
        public void evaluate() throws Throwable {
            System.out.printf("Setting up timeout: %d %s to wrap: %s\n", timeout, units, base);
            AtomicReference<Throwable> error = new AtomicReference<>();
            CountDownLatch latch = new CountDownLatch(1);
            FutureTask<Void> task = new FutureTask<>(() -> {
                try {
                    latch.countDown();// w ww  .  ja va2s . c  om
                    base.evaluate();
                } catch (Throwable t) {
                    error.set(t);
                }

                return null;
            });

            ThreadGroup tg = new ThreadGroup("Test Timeout Group");
            Thread t = new Thread(tg, task, "Test Timeout Thread");
            t.setDaemon(true);
            t.start();

            try {
                System.out.println("Waiting for test to start.");
                latch.await();
            } catch (InterruptedException e) {
                error.set(e);
            }

            if (error.get() == null) {
                try {
                    System.out.println("Waiting for test to complete (or timeout)");
                    task.get(timeout, units);
                } catch (InterruptedException e) {
                    error.set(e);
                } catch (ExecutionException e) {
                    error.set(e.getCause());
                } catch (TimeoutException e) {
                    System.out.printf("Test timeout %d %s expired!\n", timeout, units.name());
                    dumpThreads();
                    StackTraceElement[] stackTrace = t.getStackTrace();
                    Exception currThreadException = new TestTimedOutException(timeout, units);
                    if (stackTrace != null) {
                        currThreadException.setStackTrace(stackTrace);
                        t.interrupt();
                    }

                    throw currThreadException;
                }
            }

            Throwable throwable = error.get();
            if (throwable != null) {
                throw throwable;
            }
        }
    };
}