This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Java program unexpectedly giving different results each time it is run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Java program unexpectedly giving different results each time it is run" Watch "Java program unexpectedly giving different results each time it is run" New topic
Author

Java program unexpectedly giving different results each time it is run

Ashish Ramteke
Ranch Hand

Joined: Oct 24, 2012
Posts: 88
    
    1
Hello folks! I am not getting why the Java program below is givingdifferent results each tme it is run.
I have Java 7 installed on my Windows 7 Home Basic PC. This is a code from an 'excercise' from the book, Head First Java 2nd ed..
The output should obviously be:
one 98098
two 98099

Can you figure it out?

Ashish Ramteke
Ranch Hand

Joined: Oct 24, 2012
Posts: 88
    
    1
Hi guys! I found that this issue is already resolved as far as the output is concerened in the 'Beginning Java' forum.
Here is its link:
http://www.coderanch.com/t/504869/java/java/TestThreads-Code-Magnets-exercise-Head
I found this link in the 'Similar Threads' section below...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java program unexpectedly giving different results each time it is run
 
It's not a secret anymore!