File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Record Data Cache. 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 "Record Data Cache." Watch "Record Data Cache." New topic
Author

Record Data Cache.

Muthaiah Ramanathan
Ranch Hand

Joined: May 16, 2005
Posts: 102
Guys,

I am caching the record data in a hashtable and having synchronised blocks where I wait for the lock on this hashtable before creating or updating or deleting, in the corresponding methods.

Here I am synchronizing the method so that no other thread changes the recNo or data or the lockCookie while a thread a executing this method.



I am wondering if this is acceptable (or looks dump??). Any suggestion is appreciated.

Thanks,

Muthaiah.


SCJP 1.6, SCJD, SCWCD, SCBCD.

Be nice to people on the way up cos, you'll need 'em on your way down - From somewhere I can't remember!
Daniel Dalton
Ranch Hand

Joined: Mar 20, 2005
Posts: 146
It's very different to whay I'm doing, but then there are loads of ways of doing things. I'd suggest that you make very, very sure that there is no possibility of introducing a thread deadlock situation by having a sunchronised block within a synchronised method as you've suggesting.

Do you need to synchronise the method itself? As far as I can see, recNo and lockCookie are thread local variables (each thread has its own stack, so other threads can't change the values of them).
 
GeeCON Prague 2014
 
subject: Record Data Cache.