Class ThreadUtilities


  • public final class ThreadUtilities
    extends java.lang.Object
    utility methods for Thread handling
    • Method Detail

      • getAllThreads

        protected static java.util.Set getAllThreads()
      • getThreadCount

        public static int getThreadCount()
        get the number of threads, not limited by thread group or activity
      • getThreadCountMap

        public static java.util.Map getThreadCountMap()
        Returns:
        a map containing thread class Class -> instance count Integer
      • printThreadDump

        public static void printThreadDump​(java.io.PrintStream out)
      • printThreadDump

        public static java.lang.String printThreadDump()
      • getNumberOfThreadsFromExpression

        public static int getNumberOfThreadsFromExpression​(java.lang.String expression,
                                                           int defaultValue)
        Evaluates an expression and returns its value. If expression can't be evaluated a given default value will be returned. In expression you can use #cores variable which holds number of cores. In case when expression evaluates to value lower than 1 value 1 will be returned.

        Examples of valid expressions:

        • 7
        • #cores
        • #cores * 2
        • #cores - 1

        Parameters:
        expression - expression to evaluate
        defaultValue - default value which must be greater than zero
        Returns:
        value of expression or default value
      • getNumberOfAvailableCores

        public static int getNumberOfAvailableCores()