package javathreads.examples.ch15;
public class SelfLoopHandler extends PoolLoopHandler {
protected int groupSize;
public SelfLoopHandler(int start, int end, int size, int threads) {
super(start, end, threads);
groupSize = size;
}
protected synchronized LoopRange loopGetRange() {
if (curLoop >= endLoop)
return null;
LoopRange ret = new LoopRange();
ret.start = curLoop;
curLoop += groupSize;
ret.end = (curLoop<endLoop)?curLoop:endLoop;
return ret;
}
}
|