Pārlūkot izejas kodu

新增停止线程方法

woody 1 gadu atpakaļ
vecāks
revīzija
10b884b09a

+ 20 - 0
framework-common/src/main/java/com/chelvc/framework/common/util/ThreadUtils.java

@@ -102,6 +102,26 @@ public final class ThreadUtils {
         }
     }
 
+    /**
+     * 停止线程
+     *
+     * @param threads 线程对象数组
+     */
+    public static void stop(@NonNull Thread... threads) {
+        interrupt(threads);
+        join(threads);
+    }
+
+    /**
+     * 停止线程
+     *
+     * @param threads 线程对象集合
+     */
+    public static void stop(@NonNull Collection<Thread> threads) {
+        interrupt(threads);
+        join(threads);
+    }
+
     /**
      * 中断线程
      *