This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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...
 
It's not a secret anymore!