类 ThreadUtils


  • public final class ThreadUtils
    extends java.lang.Object
    Thread utils.
    作者:
    liaochuntao
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      private static int THREAD_MULTIPLER  
    • 构造器概要

      构造器 
      构造器 说明
      ThreadUtils()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static void addShutdownHook​(java.lang.Runnable runnable)  
      static void countDown​(java.util.concurrent.CountDownLatch latch)  
      static int getSuitableThreadCount()
      Through the number of cores, calculate the appropriate number of threads; 1.5-2 times the number of CPU cores.
      static int getSuitableThreadCount​(int threadMultiple)
      Through the number of cores, calculate the appropriate number of threads.
      static void latchAwait​(java.util.concurrent.CountDownLatch latch)
      Await count down latch.
      static void latchAwait​(java.util.concurrent.CountDownLatch latch, long time, java.util.concurrent.TimeUnit unit)
      Await count down latch with timeout.
      static void objectWait​(java.lang.Object object)
      Wait.
      static void shutdownThreadPool​(java.util.concurrent.ExecutorService executor)  
      static void shutdownThreadPool​(java.util.concurrent.ExecutorService executor, org.slf4j.Logger logger)
      Shutdown thread pool.
      static void sleep​(long millis)
      Sleep.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • THREAD_MULTIPLER

        private static final int THREAD_MULTIPLER
        另请参阅:
        常量字段值
    • 构造器详细资料

      • ThreadUtils

        public ThreadUtils()
    • 方法详细资料

      • objectWait

        public static void objectWait​(java.lang.Object object)
        Wait.
        参数:
        object - load object
      • sleep

        public static void sleep​(long millis)
        Sleep.
        参数:
        millis - sleep millisecond
      • countDown

        public static void countDown​(java.util.concurrent.CountDownLatch latch)
      • latchAwait

        public static void latchAwait​(java.util.concurrent.CountDownLatch latch)
        Await count down latch.
        参数:
        latch - count down latch
      • latchAwait

        public static void latchAwait​(java.util.concurrent.CountDownLatch latch,
                                      long time,
                                      java.util.concurrent.TimeUnit unit)
        Await count down latch with timeout.
        参数:
        latch - count down latch
        time - timeout time
        unit - time unit
      • getSuitableThreadCount

        public static int getSuitableThreadCount()
        Through the number of cores, calculate the appropriate number of threads; 1.5-2 times the number of CPU cores.
        返回:
        thread count
      • getSuitableThreadCount

        public static int getSuitableThreadCount​(int threadMultiple)
        Through the number of cores, calculate the appropriate number of threads.
        参数:
        threadMultiple - multiple time of cores
        返回:
        thread count
      • shutdownThreadPool

        public static void shutdownThreadPool​(java.util.concurrent.ExecutorService executor)
      • shutdownThreadPool

        public static void shutdownThreadPool​(java.util.concurrent.ExecutorService executor,
                                              org.slf4j.Logger logger)
        Shutdown thread pool.
        参数:
        executor - thread pool
        logger - logger
      • addShutdownHook

        public static void addShutdownHook​(java.lang.Runnable runnable)