This week's book giveaway is in the
We're giving away four copies of
Arduino in Action
and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Arduino in Action
this week in the
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
Threads and Synchronization
Joined: Jan 31, 2007
Jan 31, 2007 01:57:00
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???
Joined: Jun 09, 2006
Jan 31, 2007 05:07:00
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?
Joined: Jan 29, 2003
Jan 31, 2007 06:44:00
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:
- it saves me about five hours per week
Singleton Pattern - toClone
threadsafety of a singleton
Thread safety in the database access.
Question regarding Singleton pattern
A question about thread safety and servlets
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013