aspose file tools*
The moose likes Threads and Synchronization and the fly likes Synchronization 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 » Java » Threads and Synchronization
Bookmark "Synchronization" Watch "Synchronization" New topic
Author

Synchronization

Iter Jugu
Greenhorn

Joined: Jan 31, 2007
Posts: 1
I have a singleton class.
- In another class say A i get that singleton instance.
- Call a set method
- then start a thread which works on this singleton instance.

Now my problem is when one such thread is started and works on that instance another thread
is also started. this leads to sync problm.

This can be fixed using synchronization but this is not advisable as this thread has to contact a server.
Till this thread returns all other threads have to wait.

Please help me to solve this issue???
Chris Beckey
Ranch Hand

Joined: Jun 09, 2006
Posts: 116

We'll need to see some more detail but off-hand it sounds like you are synchronizing things that don't need to be synchronized.

1.) Is the singleton doing the server call?
2.) Does the state of the singleton need to be preserved for the length of the server call?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Or making a Singleton that shouldn't be. In the universe in general, there are many of those. Why must there be only one instance of this thing?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronization