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