Just the source | Back to Course Home Page |
public class CountThread extends Thread { private int from; private int to; public static void main(String[] args) { for (int i = 0; i < 5; i++) { Thread t = new CountThread(i*10, (i+1)*10); t.start(); } } public CountThread(int from, int to) { this.from = from; this.to = to; } public void run() { for (int i = from; i < to; i++) { System.out.println("i = "+i); yield(); } } }