1 package net.javacoding.jspider.mockobjects; 2 3 import net.javacoding.jspider.core.SpiderContext; 4 import net.javacoding.jspider.core.task.work.BaseWorkerTaskImpl; 5 import net.javacoding.jspider.core.task.WorkerTask; 6 7 15 public class WaitTask extends BaseWorkerTaskImpl { 16 17 18 protected int wait; 19 20 21 protected int waitDuringPrepare; 22 23 28 public WaitTask ( SpiderContext context, int wait ) { 29 this ( context, wait, 0); 30 } 31 32 37 public WaitTask ( SpiderContext context, int wait, int waitDuringPrepare ) { 38 super(context, WorkerTask.WORKERTASK_THINKERTASK); 39 this.wait = wait; 40 this.waitDuringPrepare = waitDuringPrepare; 41 } 42 43 public void prepare() { 44 if ( waitDuringPrepare > 0 ) { 45 try { 47 Thread.currentThread().wait(waitDuringPrepare); 48 } catch (InterruptedException e) { 49 Thread.currentThread().interrupt(); 50 } 51 } 52 } 53 54 58 public void execute() { 59 try { 61 Thread.currentThread().wait(wait); 62 } catch (InterruptedException e) { 63 Thread.currentThread().interrupt(); 64 } 65 } 66 67 public void tearDown() { 69 } 70 71 public int getType() { 72 return WorkerTask.WORKERTASK_THINKERTASK; 73 } 74 75 } 76 | Popular Tags |