Java Timer Usage countWorkerPoolTimerThreads()

Here you can find the source of countWorkerPoolTimerThreads()

Description

count Worker Pool Timer Threads

License

Open Source License

Declaration

public static int countWorkerPoolTimerThreads() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static final String WORKER_POOL_TIMER = "java.util.TimerThread";

    public static int countWorkerPoolTimerThreads() {
        return countThreads(WORKER_POOL_TIMER);
    }//from   w ww . j  a  v  a 2 s.co  m

    private static int countThreads(String namePattern) {
        Thread[] list = new Thread[100];
        Thread.enumerate(list);
        int matches = 0;
        for (Thread element : list) {
            if (element != null) {
                if (element.getName().matches(namePattern) || element.getClass().getName().matches(namePattern)) {
                    matches++;
                }
            }
        }
        return matches;
    }
}

Related

  1. delayedExit(final int status, final long delay)
  2. exitSystemAfterTimeout(final long delay)
  3. getMinIdleTimer()
  4. getQuickSearchTimer()