*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads Chapter Question 15: yo yo dude dude program. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads Chapter Question 15: yo yo dude dude program." Watch "Threads Chapter Question 15: yo yo dude dude program." New topic
Author

Threads Chapter Question 15: yo yo dude dude program.

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266

When I run this program I get output as :

yo yo dude dude

Whereas K & B book says :

the output could be yo dude dude yo

[Ankit: added code tags and fixed subject line]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Please UseCodeTags when you post source code (you've been here for a while, you should understand by now how to use code tags...).

jose chiramal wrote:the output could be yo dude dude yo

Pay attention to the word "could". It doesn't say it's always "yo dude dude yo".

Do you understand yourself why you get the output that you do?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8803
    
    5
Generally speaking, SCJP questions have extremely precise answers, but thread questions, by the very nature of how threads get scheduled often CANNOT have such precise answers...

So, it's really common to see imprecise words in threads questions like: "probably" or "could" or "possible" or "tends" or "most likely". Of course it's essential that you pay attention when a question uses a word like that - it means that you can't exactly predict the outcome of some code, but that you can know some things about how it will run.


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
 
Don't get me started about those stupid light bulbs.
 
subject: Threads Chapter Question 15: yo yo dude dude program.
 
Similar Threads
Thread synchronization problem K&B, SCJP 6 - chapter 9, question 15
K&B chapter 9 Threads question 15
Thread exercise
Doubt in Thread question from K&B book
Non synchronized method