class Dead { // erzeugt zwei Threads public static void main (String[] args) { final Object resource1 = new Object(); final Object resource2 = new Object(); Thread t1 = new Thread(new Runnable() { public void run() { synchronized(resource1) { System.out.println("T1 got R1"); compute(1); synchronized(resource2){ System.out.println("T1 got R2"); compute(1); } } } } ); Thread t2 = new Thread(new Runnable() { public void run() { synchronized(resource2) { System.out.println("T2 got R2"); synchronized(resource1){ System.out.println("T2 got R1"); compute(2); } } } } ); t1.setPriority(6); t1.start(); for (int k=0; k<= 2000; k++) System.out.print("+"); t2.setPriority(10); t2.start(); }; static void compute(int i){ System.out.println("Thread"+ i); for (int k=0; k<= 2000; k++) System.out.print(k+" "); } } // end Dead