This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in a Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in a Threads" Watch "Doubt in a Threads" New topic

Doubt in a Threads

Sekhar Choudary
Ranch Hand

Joined: May 03, 2008
Posts: 57
Hi , code is here

I think methods increment() and reset() should be synchronized for thread safety.
Am i right.

Milan Sutaria
Ranch Hand

Joined: Jul 10, 2008
Posts: 122
the variable Count is private. I am assuming a scenario where a single object of the class ThreadsEX4 is created & its reference is passed on to two threads, so that each thread can acces the varible & modify it.
In this i would suggest even the getCount method to be synchronized. Though i am not sure.

SCJP 6 83%
I agree. Here's the link:
subject: Doubt in a Threads
Similar Threads
It's not a secret anymore!