console - Java: System.out.println and System.err.println out of order -
my system.out.println()
, system.err.println()
calls aren't being printed console in order make them.
public static void main(string[] args) { (int = 0; < 5; i++) { system.out.println("out"); system.err.println("err"); } }
this produces:
out out out out out err err err err err
instead of alternating out
, err
. why this?
they different streams , flushed @ different times.
if put
system.out.flush(); system.err.flush();
inside loop, work expected.
to clarify, output streams cached write goes memory buffer. after period of quiet, written out.
you write 2 buffers, after period of inactivity both flushed (one after other).
Comments
Post a Comment