类 ThreadUtils

java.lang.Object
com.alibaba.nacos.common.utils.ThreadUtils

public final class ThreadUtils extends Object
Thread utils.
作者:
liaochuntao
  • 构造器详细资料

    • ThreadUtils

      public ThreadUtils()
  • 方法详细资料

    • objectWait

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

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

      public static void countDown(CountDownLatch latch)
    • latchAwait

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

      public static void latchAwait(CountDownLatch latch, long time, 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(ExecutorService executor)
    • shutdownThreadPool

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

      public static void addShutdownHook(Runnable runnable)