    @Test
    public void does_not_deadlock_if_somebody_locks_in_the_PrintStream_externally() throws Exception {

        final int ITERATIONS = 10;
        PrintStream printStream = SynchronizedPrintStream.create(new NullOutputStream(), Charset.defaultCharset(), lock);

        // will fail with a test timeout if a deadlock happens
        runConcurrently(() -> {
            // what Thread.printStackTrace() would do
            synchronized (printStream) {
                for (int i = 0; i < ITERATIONS; i++) {
                    Thread.yield();
                    printStream.print("X");
                }
            }
        }, () -> {
            // what a normal printer would do
            for (int i = 0; i < ITERATIONS; i++) {
                Thread.yield();
                printStream.print("X");
            }
        });
    }