| Author |
Some lock doubts
|
Marcio Aun Migueis
Ranch Hand
Joined: Sep 15, 2003
Posts: 32
|
|
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 ]
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10892
|
|
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
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
Marcio Aun Migueis
Ranch Hand
Joined: Sep 15, 2003
Posts: 32
|
|
Andrew, Thanks a lot. you really help me. M�rcio [ September 26, 2005: Message edited by: Marcio Aun Migueis ]
|
 |
 |
|
|
subject: Some lock doubts
|
|
|