Timing issues with PrintStreams
-
30-10-2019 - |
Question
I'm using eclipse IDE, and sometimes, depending on the code, System.err output is printed before than System.out's. For instance:
public static void main(String[] args) {
System.out.println("Regular text"); //1
System.err.println("Error text"); //2
}
With that code, everything is fine. 2 is printed after 1. However, adding some extra system.out sentences reverses the order:
public static void main(String[] args) {
System.out.println("Regular text"); //1
System.err.println("Error text"); //2
//Additional printing stuff
for(String s = "a";s.length() < 200; s = s.concat("" + (char)(s.charAt(s.length()-1)+ 1))){
System.out.println(s);
}
}
1 is printed after 2.
How is this possible?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow