Code example for PipedOutputStream

Methods: write

0
 
            boolean pass;
 
            public void run() { 
                try { 
                    pos.write(1);
                } catch (IOException e) {
                    pass = true;
                } 
            } 
        } 
        MyRunnable myRun = new MyRunnable();
        synchronized (pis) {
            t = new Thread(myRun);
            // thread t will be blocked inside pos.write(1) 
            // when it tries to call the synchronized method pis.receive 
            // because we hold the monitor for object pis 
            t.start();
            try { 
                // wait for thread t to get to the call to pis.receive 
                Thread.sleep(100);