Browse Source

线程不足导致卡死的问题

wuweifeng10 1 year ago
parent
commit
87dd12e449
1 changed files with 3 additions and 3 deletions
  1. 3 3
      src/main/java/com/jd/platform/async/wrapper/WorkerWrapper.java

+ 3 - 3
src/main/java/com/jd/platform/async/wrapper/WorkerWrapper.java

@@ -11,8 +11,8 @@ import com.jd.platform.async.worker.WorkResult;
 
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
@@ -196,8 +196,8 @@ public class WorkerWrapper<T, V> {
                     .work(executorService, WorkerWrapper.this, remainTime - costTime, forParamUseWrappers), executorService);
         }
         try {
-            CompletableFuture.allOf(futures).get();
-        } catch (InterruptedException | ExecutionException e) {
+            CompletableFuture.allOf(futures).get(remainTime - costTime, TimeUnit.MILLISECONDS);
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }