The Java Program: Simple.java
1
2
3 import java.lang.Thread;
4
5 class SimpleThread extends Thread {
6
7 public SimpleThread(String name) {
8 super(name);
9 }
10
11 public void run() {
12 for (int i = 0; i < 10; i++) {
13 System.out.println (i + " " + getName());
14 try {
15 Thread.sleep((int)(Math.random() * 1000));
16 } catch (InterruptedException e) {
17 e.printStackTrace();
18 }
19 }
20 System.out.println ("DONE! " + getName());
21 }
22 }
23
24 class Simple {
25 public static void main (String args[]) {
26 new SimpleThread("Jamaica").start();
27 new SimpleThread("Bahamas").start();
28 }
29 }