public class Range implements Runnable { int low, high; IteratorHelper ih = new IteratorHelper(this); public Range (int low, int high) { this.low = low; this.high = high; } public boolean hasNext() { return !ih.done(); } public int next() { return ih.get(); } @Override public void run() { for (int i = low; hasNext(); next()) { ih.yield(i); } } }