Example usage for java.lang ThreadGroup getClass

List of usage examples for java.lang ThreadGroup getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.flexive.shared.cache.impl.FxJBossEmbeddedCacheProvider.java

/**
 * {@inheritDoc}/*from   w  ww  .  j a v  a 2  s  .co  m*/
 */
@Override
public void shutdown() throws FxCacheException {
    cache.getCache().stop();
    cache.getCache().destroy();
    final ThreadGroup group = org.jgroups.util.Util.getGlobalThreadGroup();
    if (group.getClass().getClassLoader() == FxJBossEmbeddedCacheProvider.class.getClassLoader()) {
        // it seems that our JBoss cache instance created the group
        try {
            group.destroy();
        } catch (Exception e) {
            if (LOG.isWarnEnabled()) {
                LOG.warn("Failed to shutdown JGroups thread group: " + e.getMessage(), e);
            }
        }
    }
}

From source file:org.openmrs.util.OpenmrsClassLoader.java

private static List<Thread> listThreads(ThreadGroup group, String indent) {
    List<Thread> threadToReturn = new ArrayList<Thread>();

    log.error(indent + "Group[" + group.getName() + ":" + group.getClass() + "]");
    int nt = group.activeCount();
    Thread[] threads = new Thread[nt * 2 + 10]; //nt is not accurate
    nt = group.enumerate(threads, false);

    // List every thread in the group
    for (int i = 0; i < nt; i++) {
        Thread t = threads[i];/*  w w  w . java  2s  .c  o m*/
        log.error(indent + "  Thread[" + t.getName() + ":" + t.getClass() + ":"
                + (t.getContextClassLoader() == null ? "null cl"
                        : t.getContextClassLoader().getClass().getName() + " "
                                + t.getContextClassLoader().hashCode())
                + "]");
        threadToReturn.add(t);
    }

    // Recursively list all subgroups
    int ng = group.activeGroupCount();
    ThreadGroup[] groups = new ThreadGroup[ng * 2 + 10];
    ng = group.enumerate(groups, false);

    for (int i = 0; i < ng; i++) {
        threadToReturn.addAll(listThreads(groups[i], indent + "  "));
    }

    return threadToReturn;
}