package loimed; import java.io.IOException; import java.io.PipedReader; import java.io.PipedWriter; public class Proov3 { public static void main(String[] arg) throws Exception { Object monitor = new Object(); PipedReader pr1 = new PipedReader(); PipedWriter pw1 = new PipedWriter(); pw1.connect(pr1); Lugeja lugeja1 = new Lugeja(pw1); Kirjutaja2 k1 = new Kirjutaja2(pr1, 2000, monitor); new Thread(lugeja1).start(); new Thread(k1).start(); PipedReader pr2 = new PipedReader(); PipedWriter pw2 = new PipedWriter(); pw2.connect(pr2); Kirjutaja2 k2 = new Kirjutaja2(pr2, 3000, monitor); new Thread(k2).start(); while (true) { pw2.write("kuku\n"); synchronized (monitor) { Thread.sleep(1000); System.out.println("abc"); } } } }