static void cleanupThreads()

in src/main/java/org/apache/sling/launchpad/app/Main.java [870:902]


    static void cleanupThreads() {

        // the current thread is the SlingNotifier thread part of
        // the main thread group, whose parent is the system thread
        // group. We only care for the main thread group here
        ThreadGroup tg = Thread.currentThread().getThreadGroup();
        Thread[] active = new Thread[tg.activeCount()];
        tg.enumerate(active);
        for (Thread thread : active) {
            if (thread != null) {
                if (thread.getName().equals("FileCleaningTracker$Reaper")) {
                    // I know, but this thread is stray ...
                    // Commons-IO bundle (or consumer of it) should
                    // actually stop it
                    thread.stop();
                } else {
                    ClassLoader loader = thread.getContextClassLoader();
                    if (loader != null && loader.getClass().getName().startsWith("org.apache.felix.framework.")) {
                        thread.setContextClassLoader(null);
                    }
                }
            }
        }

        // SLING-2535 - Scheduler thread group
        ThreadGroup[] groups = new ThreadGroup[tg.activeGroupCount()];
        tg.enumerate(groups);
        for (ThreadGroup group : groups) {
            if (group != null && group.getName().equals("QuartzScheduler:ApacheSling")) {
                group.destroy();
            }
        }
    }