diff --git a/CHANGELOG.md b/CHANGELOG.md index f490cc855..82302c129 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ ### 🐣新特性 * 【core 】 CharUtil.isBlankChar增加\u180e(pr#2738@Github) +* 【core 】 SyncFinisher线程同步结束器添加立即结束方法(pr#879@Gitee) +* ### 🐞Bug修复 * 【json 】 修复普通byte数组转JSONArray时的异常(pr#875@Gitee) * 【core 】 修复ArrayUtil.insert()不支持原始类型数组的问题(pr#874@Gitee) diff --git a/hutool-core/src/main/java/cn/hutool/core/thread/SyncFinisher.java b/hutool-core/src/main/java/cn/hutool/core/thread/SyncFinisher.java index ef3022abf..a990fae2f 100644 --- a/hutool-core/src/main/java/cn/hutool/core/thread/SyncFinisher.java +++ b/hutool-core/src/main/java/cn/hutool/core/thread/SyncFinisher.java @@ -23,7 +23,6 @@ import java.util.concurrent.ExecutorService; * sf.start() * * - * * @author Looly * @since 4.1.15 */ @@ -34,9 +33,13 @@ public class SyncFinisher implements Closeable { private ExecutorService executorService; private boolean isBeginAtSameTime; - /** 启动同步器,用于保证所有worker线程同时开始 */ + /** + * 启动同步器,用于保证所有worker线程同时开始 + */ private final CountDownLatch beginLatch; - /** 结束同步器,用于等待所有worker线程同时结束 */ + /** + * 结束同步器,用于等待所有worker线程同时结束 + */ private CountDownLatch endLatch; /** @@ -123,7 +126,7 @@ public class SyncFinisher implements Closeable { public void start(boolean sync) { endLatch = new CountDownLatch(workers.size()); - if(null == this.executorService || this.executorService.isShutdown()){ + if (null == this.executorService || this.executorService.isShutdown()) { this.executorService = ThreadUtil.newExecutor(threadSize); } for (Worker worker : workers) { @@ -150,11 +153,11 @@ public class SyncFinisher implements Closeable { * * @since 5.6.6 */ - public void stop(){ - if(null != this.executorService){ + public void stop() { + if (null != this.executorService) { this.executorService.shutdown(); + this.executorService = null; } - this.executorService = null; clearWorker(); } @@ -166,13 +169,13 @@ public class SyncFinisher implements Closeable { *