stopWhenComplete,增加动态修改完成时停止方法。 (#1169)

Co-authored-by: niuxiaozu <niuxiaozu@yeah.net>
master
Niu_XZ 2024-06-17 17:27:28 +08:00 committed by GitHub
parent 49a5efff46
commit 4d0cdb011f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -85,7 +85,7 @@ public class Spider implements Runnable, Task {
protected AtomicInteger stat = new AtomicInteger(STAT_INIT);
protected boolean exitWhenComplete = true;
protected volatile boolean exitWhenComplete = true;
protected final static int STAT_INIT = 0;
@ -598,6 +598,13 @@ public class Spider implements Runnable, Task {
}
}
/**
* Stop when all tasks in the queue are completed and all worker threads are also completed
*/
public void stopWhenComplete(){
this.exitWhenComplete = true;
}
/**
* start with more than one threads
*