KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > javacoding > jspider > mockobjects > WaitTaskDispatcherTask


1 package net.javacoding.jspider.mockobjects;
2
3 import net.javacoding.jspider.core.SpiderContext;
4 import net.javacoding.jspider.core.task.dispatch.BaseDispatchTaskImpl;
5 import net.javacoding.jspider.core.threading.WorkerThreadPool;
6
7 /**
8  * Mock implementation of a dispatcher task. It will simply dispatch a
9  * configured amount of Wait tasks to the pool.
10  *
11  * $Id: WaitTaskDispatcherTask.java,v 1.3 2003/03/27 17:44:32 vanrogu Exp $
12  *
13  * @author Günther Van Roey
14  */

15 public class WaitTaskDispatcherTask extends BaseDispatchTaskImpl {
16
17     /** The thread pool we'll be dispatching tasks to. */
18     protected WorkerThreadPool threadPool;
19
20     /** number of tasks to dispatch. */
21     protected int count;
22
23     /** amount of milliseconds to wait in a task. */
24     protected int wait;
25
26     /**
27      * Public constructor.
28      * @param count nr of tasks to dispatch
29      * @param wait nr of ms to wait in these tasks
30      */

31     public WaitTaskDispatcherTask(WorkerThreadPool threadPool, SpiderContext context, int count, int wait) {
32         super(context);
33         this.threadPool = threadPool;
34         this.count = count;
35         this.wait = wait;
36     }
37
38     public void execute() {
39         for ( int i = 0; i < count; i++ ) {
40            threadPool.assign(new WaitTask(context, wait));
41         }
42     }
43
44 }
45
Popular Tags