类 ThreadUtils
- java.lang.Object
-
- com.alibaba.nacos.common.utils.ThreadUtils
-
public final class ThreadUtils extends java.lang.ObjectThread utils.- 作者:
- liaochuntao
-
-
字段概要
字段 修饰符和类型 字段 说明 private static intTHREAD_MULTIPLER
-
构造器概要
构造器 构造器 说明 ThreadUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static voidaddShutdownHook(java.lang.Runnable runnable)static voidcountDown(java.util.concurrent.CountDownLatch latch)static intgetSuitableThreadCount()Through the number of cores, calculate the appropriate number of threads; 1.5-2 times the number of CPU cores.static intgetSuitableThreadCount(int threadMultiple)Through the number of cores, calculate the appropriate number of threads.static voidlatchAwait(java.util.concurrent.CountDownLatch latch)Await count down latch.static voidlatchAwait(java.util.concurrent.CountDownLatch latch, long time, java.util.concurrent.TimeUnit unit)Await count down latch with timeout.static voidobjectWait(java.lang.Object object)Wait.static voidshutdownThreadPool(java.util.concurrent.ExecutorService executor)static voidshutdownThreadPool(java.util.concurrent.ExecutorService executor, org.slf4j.Logger logger)Shutdown thread pool.static voidsleep(long millis)Sleep.
-
-
-
字段详细资料
-
THREAD_MULTIPLER
private static final int THREAD_MULTIPLER
- 另请参阅:
- 常量字段值
-
-
方法详细资料
-
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 latchtime- timeout timeunit- 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 poollogger- logger
-
addShutdownHook
public static void addShutdownHook(java.lang.Runnable runnable)
-
-