File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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!