Forums Register Login

Some lock doubts

+Pie Number of slices to send: Send
Hi ,

I�m using the following map to manage my locked records


The key value is the record number, and the contents is the cookie. Is this approach correct ? May I use the Java 5 generics to define my map ?

My lock method is

Supose we have two clients trying to lock the same record. Before the put command, Client A put his cookie in the map. After that, client B put his own cookie. How to avoid this situation ? Do we have to synchronize the whole method ? Inserting synchronized to my method signature, Am I changing my interface specifications ?

Thanks in advance,

M�rcio
[ September 24, 2005: Message edited by: Marcio Aun Migueis ]
+Pie Number of slices to send: Send
Hi M�rcio,

May I use the Java 5 generics to define my map ?

Yes, you certainly can, and it is a good idea to do so.

Supose we have two clients trying to lock the same record. Before the put command, Client A put his cookie in the map. After that, client B put his own cookie. How to avoid this situation ? Do we have to synchronize the whole method ? Inserting synchronized to my method signature, Am I changing my interface specifications ?

According to the JLS "an interface may be implemented by a method that is declared strictfp or native or synchronized in a class that implements the interface."

Regards, Andrew
+Pie Number of slices to send: Send
Andrew,

Thanks a lot. you really help me.


M�rcio
[ September 26, 2005: Message edited by: Marcio Aun Migueis ]
Seriously Rick? Seriously? You might as well just read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 795 times.
Similar Threads
SCJD failed, help needed with locking!
I passed, but I suffered the 44/80 locking penalty. Why?
Lock Cookie
B&S: Why lock and update/delete throw RecordNotFoundException?
DeadLock
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:23:22.