| class  Demo1 implements Runnable {
 Object obj=new Object();
 public void run()
 {
 while(true)
 {
 synchronized(obj)
 {
 try
 {
 Thread.sleep(10);
 }
 catch(Exception e)
 {
 System.out.println(e.toString());
 }
 System.out.println(Thread.currentThread().getName()+"****show");
 }
 }
 }
 }
 class Demo2
 {
 Demo1 d=new Demo1();
 Thread t1=new Thread(d);
 Thread t2=new Thread(d);
 t1.start();
 t2.start()
 }
 |