The moose likes Threads and Synchronization and the fly likes Synchronization Question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Synchronization Question" Watch "Synchronization Question" New topic
Author

Synchronization Question

Vic Newman
Ranch Hand

Joined: Mar 01, 2002
Posts: 33
If you have multiple threads with each thread creating an instance of foo.class, what methodology would you suggest to implement method synchronization in foo besides making foo static?
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Vic
If each thread has its own instance of a foo object what is there to synchronize? Or is there some class member that needs to be synchronized in the foo object?
If it is a class (static) member of class foo just create getter and setter methods in the foo class and synchronize the methods - or just part of the methods if they are large.
hope that helps
Dave


Dave
 
 
subject: Synchronization Question
 
Threads others viewed
Double-checked locking and Singleton
Double-checked locking and Singleton
Need a single instance of object.
Thread taking turns
Is this a valid Singleton wrapper class
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture