The class TeeOutputStream is used to redirect System.out, and so is used from multiple threads. It is, however, not thread-safe.
The relevant part of the code is the following:
class TeeOutputStream {
private OutputStream log;
public void closeLog() { log = null; }
public void write() { if (log != null) /* here another thread calls closeLog */ log.write(); }
}
I have observed this bug with the tomcat benchmark. But, being a concurrency bug, it is hard to reproduce.