4

Possible Duplicate:
Java: System.out.println and System.err.println out of order

Why this code

    System.err.println("err");
    System.out.println("out");

prints

out
err

on Eclipse console?

UPDATE

The same code prints in correct order if I run it from command line.

UPDATE

If I fix it as

    System.err.println("err");
    Thread.sleep(5);
    System.out.println("out");

It prints correctly in Eclipse too

Community
  • 1
  • 1
Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275

1 Answers1

4

It's not slower; they're just not necessarily flushed in order. You can fix that, however:

System.err.println("err");
System.err.flush();
System.out.println("out");

Okay, so this appears to be a known Eclipse bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=32205

Matt Ball
  • 354,903
  • 100
  • 647
  • 710