<div dir="ltr">Ahhh, OK, jtreg is using System.setOut(out); which is how the java and C++ output ends up in different destinations.  So yes, nothing to do with buffering.  I'll update my internal mental model of how jtreg works.  It would be nice if jtreg could capture both together, but that might take a lot of non-java plumbing.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 8, 2018 at 7:05 PM, David Holmes <span dir="ltr"><<a href="mailto:david.holmes@oracle.com" target="_blank">david.holmes@oracle.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Martin, Roger,<br>
<br>
On 7/07/2018 12:55 AM, Martin Buchholz wrote:<span class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
On Fri, Jul 6, 2018 at 6:44 AM, Roger Riggs <<a href="mailto:Roger.Riggs@oracle.com" target="_blank">Roger.Riggs@oracle.com</a> <mailto:<a href="mailto:Roger.Riggs@oracle.com" target="_blank">Roger.Riggs@oracle.com</a><wbr>>> wrote:<br>
<br>
    Hi David,<br>
<br>
    stdout and system.out are buffered, so you might need to look at<br>
    when/if flush is called.<br>
</blockquote>
<br></span>
Newlines trigger flushing and that occurs in both cases.<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
More to the point, they use independent buffers.<br>
See also Java Puzzler 81 Charred Beyond Recognition<br>
<a href="https://books.google.com/books?id=RM9sLE0ntQ0C&pg=RA1-PT231&dq=Java+Puzzler+81+Charred+Beyond+Recognition&hl=en&sa=X&ved=0ahUKEwiboLSw3YrcAhXIslQKHZeVDtcQ6AEIKTAA#v=onepage&q=Java%20Puzzler%2081%20Charred%20Beyond%20Recognition&f=false" rel="noreferrer" target="_blank">https://books.google.com/books<wbr>?id=RM9sLE0ntQ0C&pg=RA1-PT231&<wbr>dq=Java+Puzzler+81+Charred+<wbr>Beyond+Recognition&hl=en&sa=X&<wbr>ved=0ahUKEwiboLSw3YrcAhXIslQKH<wbr>ZeVDtcQ6AEIKTAA#v=onepage&q=<wbr>Java%20Puzzler%2081%20Charred%<wbr>20Beyond%20Recognition&f=false</a><br>
</blockquote>
<br></span>
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" ??<br>
<br>
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:<br>
<br>
/export/users/dh198349/jdk11/o<wbr>pen/test/hotspot/jtreg > ../../../../build/linux-x64-de<wbr>bug/images/jdk/bin/java -cp ./JTwork/classes/runtime/jni/t<wbr>erminatedThread/TestTerminated<wbr>Thread.d/ -Djava.library.path=/export/us<wbr>ers/dh198349/jdk11/build/linux<wbr>-x64-debug/images/test/hotspot<wbr>/jtreg/native/ TestTerminatedThread<br>
Native thread is running and attaching as daemon ...<br>
Native thread terminating<br>
Working with thread: Thread[Thread-0,5,main],  in state: RUNNABLE<br>
Calling suspend ...<br>
Calling resume ...<br>
Calling getStackTrace ...<br>
...<br>
<br>
So the difference is with how jtreg is intercepting/redirecting the different streams from the process.<br>
<br>
Not a problem, just something I noticed and wanted to double-check.<br>
<br>
Cheers,<br>
David<br>
</blockquote></div><br></div>