cardil commented on a change in pull request #112: Adding support for externally passed random seed and printing used seed on console URL: https://github.com/apache/maven-surefire/pull/112#discussion_r286841579
########## File path: surefire-its/src/test/resources/testng-parallel-suites/src/test/java/testng/suiteXml/TestNGSuiteTest.java ########## @@ -28,16 +28,23 @@ * @author <a href="mailto:tibordig...@apache.org">Tibor Digana (tibor17)</a> * @since 2.19 */ -public class TestNGSuiteTest { - private static final AtomicInteger counter = new AtomicInteger(); +public class TestNGSuiteTest +{ + private static final AtomicInteger counter = new AtomicInteger(); - @Test - public void shouldRunAndPrintItself() - throws Exception - { - System.out.println( getClass().getSimpleName() + "#shouldRunAndPrintItself() " - + counter.incrementAndGet() + "."); + @Test + public void shouldRunAndPrintItself() throws Exception + { + String message = String.format( + "%s#shouldRunAndPrintItself() %d.", + getClass().getSimpleName(), + counter.incrementAndGet() + ); + TimeUnit.SECONDS.sleep( 1 ); - TimeUnit.SECONDS.sleep( 2 ); - } + synchronized ( System.out ) Review comment: It depends on how you write to `OutputStream`. Usually you got a single writer, like with using a logging framework. Every thread gets the same instance of writer. Such writer will usually buffer writing to a stream and in that way, each mesage is treated as separate. In this test, there are seperate threads that write bytes directly to `OutputStream`, without buffering or synchronization. This is the reason that here synchronization helps. But it might or might not be needed in production code. It depends. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services