class DispTask extends Thread { boolean doYield; DispTask(boolean _doYield) { doYield = _doYield; } public void run() { for (int i = 0; i < 10; i++) { System.out.println(i); if (doYield) yield(); } } }