This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Synchronized methods in Data class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Synchronized methods in Data class" Watch "Synchronized methods in Data class" New topic
Author

Synchronized methods in Data class

Baris Dere
Ranch Hand

Joined: Mar 23, 2004
Posts: 31
Hi guys,

I implemented lock and unlock methods with synchronized blocks. And locking called within update and delete methods of the Data class on the server side. On the client side I didn't implement locking. My question is now.. Must I also set the modifier of all methods of the Data class as synchronized? Some of people did. But why should I do that?

Can someone help me to splve this problem?

Thanks

Regards

Baris Dere
YungSheng Chang
Ranch Hand

Joined: Jul 28, 2003
Posts: 44
Hi Baris,
I think this is a very fundemental and important question in SCJD. Make sure you know what you mean when you add synchronized on a method. It is actually locking the corresponding object for that thread. Therefore, the question should not be "synchronize all method", it instead should be "overall locking mechanism".
In Max Habibi's book he suggest to synchorize all public methods. If you use the same wrapper class design, maybe it is a good idea. Still, the question goes to your locking mechanism.


I play Java for fun.<br /> <br />SCJP / SCJD / SCWCD / SCBCD
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Baris,

And locking called within update and delete methods of the Data class on the server side.


Are you sure it's compatible with your instructions? In mine, locking methods may be called server-side, but only from outside of the update and delete methods.

Regards,

Phil.
 
Consider Paul's rocket mass heater.
 
subject: Synchronized methods in Data class
 
Similar Threads
Data.java
NX: Why do you all make LockManagers?
Lock design
B&S: Simplest locking successful?
not sure which methods must be synchronized