• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Chapter 7, Question 17  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the code of question 17, I chagne 100 bu 10000000 in the for loop.
And guess what happened?
i got this!!!
9947604 9948034
If someone can explain me this.
Thank you

 
Marshal
Posts: 24195
54
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You print those values before you call the service's shutdown() method, so it's possible that the service hasn't processed all of its executions yet.

At least... I'm answering one question you didn't ask, namely why isn't either of the values 10000000? Another question you didn't ask is why aren't the two values the same, but I chose not to answer that.

It's impossible to answer why the first value is 9947604 and not some other value, for example 9947623. I think you actually asked that question, but it's quite likely you meant to ask one of the other questions which I chose.

Also, if you're asking about a question in a certification exam, please tell us which exam and post the whole question.
 
vincent Lepore
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Thank you for your answer.

It was the Question 7 from chapter 7 of the OCP study guide written by Jeanne BOyarsky and scott Selikoff.

The value numbers were not so important.

I just wanted to know why i didn't get 10000000 10000000 .
And you gave me th e explanation

Thank you very much.
Vincent

 
vincent Lepore
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Paul,

I updated the code, putting in comment the line below.
//if(service != null) service.shutdown();
Of course, it hanged at runtime.

But it didn't display 10000000 10000000.
It display values lower than 10000000 and different for sheepCount1 and sheepCount2.

So it seems that the service.shutdown() would not be the explaination of this result.

If someone has an idea.
Thanks
Vincent
 
Rancher
Posts: 3080
108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Vincent,

this question was raised before. Have a look at this topic:
same question
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!