@Test(timeout = 1000)
    public void testConcurrentReaderPiping() throws Exception {
        final int charCount = 30;
        final char[] vals = "123456789".toCharArray();
        final int n = vals.length;
        Reader[] readers = new Reader[n];
        // Generate n readers with charCount equal elements in them.
        for (int i = 0; i < n; i++) {
            String s = "";
            for (int j = 0; j < charCount; j++) {
                s += vals[i];
            }
            StringReader sr = new StringReader(s);
            readers[i] = new SlowReader(sr);
        }
        StringWriter wrt = new StringWriter();
        Pipe[] pipes = new Pipe[n];
        for (int i = 0; i < n; i++) {
            pipes[i] = new Pipe(readers[i], wrt);
        }
        for (int i = 0; i < n; i++) {
            pipes[i].start();
        }
        for (int i = 0; i < n; i++) {
            pipes[i].join();
            readers[i].close();
        }

        // Count up elements and ensure that we've got the correct amount of
        // characters of each type.
        String out = wrt.toString();
        char[] output = out.toCharArray();
        wrt.close();
        for (char v : vals) {
            int sum = 0;
            for (char c : output) {
                if (c == v) {
                    sum++;
                }
            }
            assertEquals(charCount, sum);
        }
    }