Return spider in setEmptySleepTime itself for chainning.

master
Joe Zhou 2022-11-12 11:06:08 +08:00
parent ac912e8f1f
commit 075b98291b
1 changed files with 6 additions and 3 deletions

View File

@ -333,9 +333,10 @@ public class Spider implements Runnable, Task {
} }
} else { } else {
// wait until new url added // wait until new url added
if (waitNewUrl()) if (waitNewUrl()) {
//if interrupted //if interrupted
break; break;
}
continue; continue;
} }
} }
@ -805,11 +806,13 @@ public class Spider implements Runnable, Task {
* Set wait time when no url is polled.<br><br> * Set wait time when no url is polled.<br><br>
* *
* @param emptySleepTime In MILLISECONDS. * @param emptySleepTime In MILLISECONDS.
* @return this
*/ */
public void setEmptySleepTime(long emptySleepTime) { public Spider setEmptySleepTime(long emptySleepTime) {
if(emptySleepTime<=0){ if(emptySleepTime<=0){
throw new IllegalArgumentException("emptySleepTime should be more than zero!"); throw new IllegalArgumentException("emptySleepTime should be more than zero!");
} }
this.emptySleepTime = emptySleepTime; this.emptySleepTime = emptySleepTime;
return this;
} }
} }