package examples;
class CounterThread extends Thread {
static int threadCount = 0;
int threadNum;
public CounterThread() {
threadNum = threadCount++;
}
public static void main(String args[]) {
CounterThread ct1 = new CounterThread();
CounterThread ct2 = new CounterThread();
CounterThread ct3 = new CounterThread();
ct1.start();
ct2.start();
ct3.start();
}
public void run() {
for (int i = 0; i <= 10; i++) {
System.out.println("Thread " +
threadNum + " : " + i);
try {
sleep((long) (Math.random() * 100.0));
} catch (InterruptedException e) {
}
}
}
}