类 Threads
- java.lang.Object
-
- net.dongliu.commons.concurrent.Threads
-
public class Threads extends java.lang.ObjectUtils for thread
-
-
构造器概要
构造器 构造器 说明 Threads()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static <T> java.util.concurrent.CompletableFuture<T>callAsync(java.util.concurrent.Callable<T> callable)Start a thread, run task async, and return future contains the result.static java.util.concurrent.CompletableFuture<java.lang.Void>runAsync(java.lang.Runnable runnable)Start a thread, run task async, and return a future.static voidsleep(java.time.Duration duration)Sleep with nanos uniterruptabllystatic voidsleepMills(long millis)Sleep with millis uniterruptabllystatic voidsleepNanos(long nanos)Sleep with nanos uniterruptabllystatic voidsleepSeconds(double seconds)Sleep with seconds uniterruptabllystatic java.lang.Threadstart(java.lang.Runnable runnable)Start a new thread to run the runnable
-
-
-
方法详细资料
-
start
public static java.lang.Thread start(java.lang.Runnable runnable)
Start a new thread to run the runnable- 参数:
runnable- the runnable to run- 返回:
- the new thread
-
runAsync
public static java.util.concurrent.CompletableFuture<java.lang.Void> runAsync(java.lang.Runnable runnable)
Start a thread, run task async, and return a future. When task finished, the thread exits.
-
callAsync
public static <T> java.util.concurrent.CompletableFuture<T> callAsync(java.util.concurrent.Callable<T> callable)
Start a thread, run task async, and return future contains the result. When task finished, the thread exits.
-
sleep
public static void sleep(java.time.Duration duration)
Sleep with nanos uniterruptablly- 参数:
duration- the time to sleep
-
sleepSeconds
public static void sleepSeconds(double seconds)
Sleep with seconds uniterruptablly- 参数:
seconds- the time to sleep
-
sleepMills
public static void sleepMills(long millis)
Sleep with millis uniterruptablly- 参数:
millis- the time to sleep
-
sleepNanos
public static void sleepNanos(long nanos)
Sleep with nanos uniterruptablly- 参数:
nanos- the time to sleep
-
-