gvsig-raster / org.gvsig.raster.cache / trunk / org.gvsig.raster.cache / org.gvsig.raster.cache.lib.impl / src / main / java / org / gvsig / raster / cache / tile / impl / pool / ThreadTask.java @ 990
History | View | Annotate | Download (641 Bytes)
1 |
package org.gvsig.raster.cache.tile.impl.pool; |
---|---|
2 |
|
3 |
/**
|
4 |
* This represents one thread in the pool. This thread gets a new task in
|
5 |
* the pool and executes it.
|
6 |
*
|
7 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
8 |
*/
|
9 |
class ThreadTask extends Thread { |
10 |
private ThreadPoolImpl pool = null; |
11 |
private boolean stop = false; |
12 |
private Runnable currentJob = null; |
13 |
|
14 |
public ThreadTask(ThreadPoolImpl thePool) {
|
15 |
pool = thePool; |
16 |
} |
17 |
|
18 |
public void run() { |
19 |
while (!stop) {
|
20 |
currentJob = pool.getNext(); |
21 |
currentJob.run(); |
22 |
} |
23 |
} |
24 |
|
25 |
/**
|
26 |
* Stops this thread
|
27 |
*/
|
28 |
public Runnable stopThread() { |
29 |
stop = true;
|
30 |
return currentJob;
|
31 |
} |
32 |
} |