wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Design Question... 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 "Design Question..." Watch "Design Question..." New topic
Author

Design Question...

Daniel Pereira
Greenhorn

Joined: May 31, 2006
Posts: 2
I'm not planning on sending my solution to Sun like this, but if I synchronize a singleton data object like so:

synchronized (myData) {

switch(request.getAction()){
CASE SEARCH:
myData.search_method...
break;
CASE UPDATE:
myData.update_method...
break;
}

}

Wouldn't locking and unlocking individual records be redundant? Would I fail if I implemented the lock methods and called them even though concurrent threads would never be able to access the same record because they'd have to queue up through a synchronized bottleneck switch? Opinions? Is there a race condition scenario I'm not thinking about? I understand that I *must* implement locking the way described in the interface, but for a low-volume application this design seems like an arguable solution.

DP
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design Question...
 
Similar Threads
Singleton & multithread env.
Synchronized data
Multi-threading programming: we do not need lock() unlock() at all
switch statement
Strange bug in a class I wrote (not sure how to explain in title)