File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in a Threads" Watch "Doubt in a Threads" New topic
Author

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.

Thanks
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%
Working on SCWCD/OCPJWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in a Threads
 
Similar Threads