我當時試圖從wiki責任鏈文章的Logger例子。 運行在想法例如,它打印:爲什麼在System.out.println之前打印System.err.println?
Sending to stderr: An error has occurred.
Writing to stdout: Entering function y.
Writing to stdout: Step1 completed.
Sending via email: Step1 completed.
Writing to stdout: An error has occurred.
Sending via email: An error has occurred.
但是當我把一個破發點中stderrs的WriteMessage
class StderrLogger extends Logger {
public StderrLogger(int mask) {
this.mask = mask;
}
protected void writeMessage(String msg) {
System.err.println("Sending to stderr: " + msg);//break out here
}
}
它打印除了STD ERR所有messags,沒有這裏涉及到, 線程那麼爲什麼它的印刷stderr在第一線運行的情況下?在Eclipse中,
流可以有不同的緩衝,不同的沖洗等 – 2013-04-26 12:19:50