21 Feb 2014, 12:14
Generic-user-small

Luciano Ramalho (1 post)

I just started reading your book and am thoroughly enjoying it, thanks!

For the first HelloWorld.java example I have a simple suggestion: add a line like Thread.sleep(1); right after myThread.start();. This will pretty much ensure that “Hello from new thread” appears after “Hello from main thread” in the output, even if it is just a 1ms delay.

Adding that line also provides your reader for an opportunity for a simple experiment: commenting out the sleep call will very likely reverse the ordering of the output.

24 Feb 2014, 14:14
Icon_pragsmall

Paul Butcher (26 posts)

That’s an excellent suggestion, Luciano. I’m kicking myself that I didn’t think of it :-)

Will do, and thanks!

  You must be logged in to comment