Code example for PipedInputStream

Methods: read

0
 
            boolean pass;
 
            public void run() { 
                try { 
                    pis.read();
                    pass = true;
                } catch (IOException e) {
                } 
            } 
        } 
        ; 
        ReadRunnable readRunnable = new ReadRunnable();
        Thread readThread = new Thread(readRunnable);
        writeThread.start();
        readThread.start();
        while (readThread.isAlive()) {
            ; 
        } 
        writeRunnable.readerAlive = false;
        assertTrue("reader thread failed to read", readRunnable.pass);