import java.util.*; import java.util.concurrent.*; public class Counter3 implements Runnable { protected int count; protected int inc; protected int delay; public Counter3(int init, int inc, int delay) { this.count = init; this.inc = inc; this.delay = delay; } public void run() { try { for (int i = 0; i < 5; i++) { System.out.print(count + " "); count += inc; Thread.sleep(delay); } } catch (InterruptedException e) {} } public static void main(String[] args) { ExecutorService executor = Executors.newCachedThreadPool(); executor.execute (new Counter3(0, 1, 333)); executor.execute (new Counter3(0, -1, 1000)); executor.shutdown(); } }