• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sybex OCA OCP Practice Test online Chapter 19 Q.23  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

First of all I would like to thank you for the great job with OCA/OCP Java SE8 Programmer Practive Tests Book!

I tried the code in Sybex OCA OCP Practice Test online Chapter 19 Q.23 with: "static int count=0;".



And as explained in the answer : If count was marked static, then the application would sum the elements correctly, printing 10. Indeed, it prints 10 correctly.
My question is: Why is it not needed to declare count as Atomic variable?
As more threads are working with count concurrently, I thought it would be necessary in order to keep consistency.

Please help me to understand!

Thanks

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!