类 ThreadUtils
java.lang.Object
com.alibaba.nacos.common.utils.ThreadUtils
Thread utils.
- 作者:
- liaochuntao
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static voidaddShutdownHook(Runnable runnable)static voidcountDown(CountDownLatch latch)static intThrough 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(CountDownLatch latch)Await count down latch.static voidlatchAwait(CountDownLatch latch, long time, TimeUnit unit)Await count down latch with timeout.static voidobjectWait(Object object)Wait.static voidshutdownThreadPool(ExecutorService executor)static voidshutdownThreadPool(ExecutorService executor, org.slf4j.Logger logger)Shutdown thread pool.static voidsleep(long millis)Sleep.
-
构造器详细资料
-
ThreadUtils
public ThreadUtils()
-
-
方法详细资料
-
objectWait
Wait.- 参数:
object- load object
-
sleep
public static void sleep(long millis)Sleep.- 参数:
millis- sleep millisecond
-
countDown
-
latchAwait
Await count down latch.- 参数:
latch- count down latch
-
latchAwait
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
-
shutdownThreadPool
Shutdown thread pool.- 参数:
executor- thread poollogger- logger
-
addShutdownHook
-