为什么System.err在Eclipse中比System.out慢? [英] Why is System.err slower than System.out in Eclipse?

查看:220
本文介绍了为什么System.err在Eclipse中比System.out慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

Java:System.out.println和System.err.println无序


为什么这个代码

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

打印

 <$在Eclipse控制台上c $ c> out 
err



更新



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

更新



如果我将其修正为

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

它在Eclipse中正确打印

解决方案

不慢;它们不一定是刷新按顺序。但是,您可以修复:

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






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


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

解决方案

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

这篇关于为什么System.err在Eclipse中比System.out慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆