• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Some lock doubts

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marcio Aun Migueis
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew,

Thanks a lot. you really help me.


M�rcio
[ September 26, 2005: Message edited by: Marcio Aun Migueis ]
 
Stop it! You're embarassing me! And you are embarrassing this tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic