1 class CallMe {
2 /*synchronized*/public void call(String msg) {
3 System.out.print("[" + msg);
4 try {
5 Thread.sleep(1000);
6 }
7 catch (Exception e){};
8 System.out.println("]");
9 }
10 }
11 class Caller implements Runnable {
12 private String msg;
13 private CallMe target;
14 public Caller(Callme t, String s) {
15 target = t;
16 msg = s;
17 new Thread(this).start();
18 }
19 public void run() {
20 //synchronized(target){
21 target.call(msg);
22 //}
23 }
24 }
25 public class Synch {
26 public static void main(String args[]) {
27 CallMe target = new CallMe();
28 new Caller(target, "Hello");
29 new Caller(target, "Synchronized");
30 new Caller(target, "World");
31 }
32 }