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.
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!
posted 11 years ago
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).
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads