类 Threads


  • public class Threads
    extends java.lang.Object
    Utils 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 void sleep​(java.time.Duration duration)
      Sleep with nanos uniterruptablly
      static void sleepMills​(long millis)
      Sleep with millis uniterruptablly
      static void sleepNanos​(long nanos)
      Sleep with nanos uniterruptablly
      static void sleepSeconds​(double seconds)
      Sleep with seconds uniterruptablly
      static java.lang.Thread start​(java.lang.Runnable runnable)
      Start a new thread to run the runnable
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • Threads

        public Threads()
    • 方法详细资料

      • 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