import java.io.*; class First extends Thread { First() { System.out.println("Starting first"); start(); } synchronized public void run() { new Second(this); try { wait(); } catch (InterruptedException e) {} System.out.println("Wait ended"); } } class Second extends Thread { First f; Second(First F) { f = F; System.out.println("Starting second"); start(); } public void run() { System.out.println("entering sleep()"); try { sleep(1500); } catch(Exception e) {} synchronized(f) { f.notifyAll(); } } } public class Threx44 { public static void main(String args[]) { char c; try {c = (char)System.in.read(); System.out.println(c); } catch (IOException e) {System.out.println("chyba cteni"); } new First(); } }