• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Threads Chapter Question 15: yo yo dude dude program.

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
The new gardening playing cards kickstarter is now live!
https://www.kickstarter.com/projects/paulwheaton/garden-cards
reply
    Bookmark Topic Watch Topic
  • New Topic