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("Thread 1 got resource 1");
          compute(1);
          try{ Thread.sleep(1000);
		      } catch (InterruptedException e) {}
					synchronized(resource2){
  	      	System.out.println("Thread 1 got resource 2");
						compute(1);
						}
					}
				}
			}
		);
		Thread t2 = new Thread (new Runnable() {
			public void run() {
				synchronized(resource2) { 
	      	System.out.println("Thread 2 got resource 2");
					System.out.println();
					synchronized(resource1){
	      	  System.out.println("Thread 2 got resource 1");
						compute(2);
						}
					}
				}
			}
		);
		t1.setPriority(3);
		t1.start();
		t2.setPriority(10);
		t2.start();
	};
	
	static void compute(int i){
		System.out.println("Thread" + i);
		for (int k=0; k<= 100; k++) System.out.print(k);
		System.out.println();
	}
}  // end Dead 
		
