• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Some lock doubts

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Andrew,

Thanks a lot. you really help me.


M�rcio
[ September 26, 2005: Message edited by: Marcio Aun Migueis ]
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic