java - 为什么 System.err 在 Eclipse 中比 System.out 慢?

标签 java eclipse stderr stdio

<分区>

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

为什么要写这段代码

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

打印

out
err

在 Eclipse 控制台上?

更新

如果我从命令行运行相同的代码,它会以正确的顺序打印。

更新

如果我把它改成

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

它在 Eclipse 中也能正确打印

最佳答案

它并不慢;他们不一定是flushed为了。但是,您可以解决这个问题:

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

好的,这似乎是一个已知的 Eclipse 错误:https://bugs.eclipse.org/bugs/show_bug.cgi?id=32205

关于java - 为什么 System.err 在 Eclipse 中比 System.out 慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13656681/

相关文章:

python - Python 中的 "stderr"有什么意义?

java - 处理并行数组

java - 如何创建独立的可执行jar文件

java - 如何用java记录Minecraft玩家的视线位置

eclipse - 从SpringSource Tool Suite(STS)运行集中的Groovy单元测试

python - 标准错误上的 Paramiko recv()/read()/readline(s)() 返回空字符串

java - 全局状态变量的静态与实例

Java流控制

java - 线程中出现异常 "main"java.util.InputMismatchException 错误消息