Code example for PipedReader

Methods: read

0
        class ReadRunnable implements Runnable {
            boolean pass;
 
            public void run() { 
                try { 
                    pr.read();
                    pass = true;
                } catch (IOException e) {
                  //ignore 
                } 
            } 
        } 
        ReadRunnable readRunnable = new ReadRunnable();
        Thread readThread = new Thread(readRunnable);
        writeThread.start();
        readThread.start();
        while (readThread.isAlive()) {
            //wait the reader thread dead 
        } 
        writeRunnable.readerAlive = false;
        assertTrue("reader thread failed to read", readRunnable.pass);