FileDocCategorySizeDatePackage
SelfLoopHandler.javaAPI DocExample554Thu Mar 11 19:51:02 GMT 2004javathreads.examples.ch15

SelfLoopHandler.java

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;
    }
}