Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads Chapter Question 15: yo yo dude dude program.

 
jose chiramal
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 15435
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic