permaculture playing cards*
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
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: 86
    
    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?



Good day..! :-)
Ashish Ramteke
Ranch Hand

Joined: Oct 24, 2012
Posts: 86
    
    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
 
Similar Threads
TestThreads Code Magnets exercise Head First Java
Why doesn't this code work in Netbeans 7.0?
join() method in Thread doesn't work as expected
Use of Private Constructor in Thread Example
Threads/Looping: How Can This Be?