System.out versus stdout output order

David Holmes david.holmes at
Mon Jul 9 02:05:52 UTC 2018

Hi Martin, Roger,

On 7/07/2018 12:55 AM, Martin Buchholz wrote:
> On Fri, Jul 6, 2018 at 6:44 AM, Roger Riggs <Roger.Riggs at 
> <mailto:Roger.Riggs at>> wrote:
>     Hi David,
>     stdout and system.out are buffered, so you might need to look at
>     when/if flush is called.

Newlines trigger flushing and that occurs in both cases.

> More to the point, they use independent buffers.
> See also Java Puzzler 81 Charred Beyond Recognition

I can't see the solution to Puzzler 81 but am assuming it just relates 
to buffering. I can't see how it relates to "independent buffers" ??

AFAIK System.out is connected to stdout for the process, and C printf 
also writes to stdout, hence I would have expected, in the normal case 
that I would see the output in the correct temporal order. And indeed 
when run directly that is the case:

/export/users/dh198349/jdk11/open/test/hotspot/jtreg > 
../../../../build/linux-x64-debug/images/jdk/bin/java -cp 
Native thread is running and attaching as daemon ...
Native thread terminating
Working with thread: Thread[Thread-0,5,main],  in state: RUNNABLE
Calling suspend ...
Calling resume ...
Calling getStackTrace ...

So the difference is with how jtreg is intercepting/redirecting the 
different streams from the process.

Not a problem, just something I noticed and wanted to double-check.


More information about the jtreg-use mailing list