• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URLyBIRD lock question

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I need to implement the lock mechanism for the URLyBIRD system. What is the best way to do it?

I was thinking of these 2 ways:
1. Have the internals of the method synchronized and just have a static long incremented each time the method is called. That way we ensure the number is unique to each person during the running of the program.
2. Use a Random function with the time as a seed to get a semi unique long integer.

Any other suggestions or which way is best?

Thanks,
Mark
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

Probably both are acceptable solutions. I would prefer the first one, because it guaruantees that the handed out cookies are unique.

Frans.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i personally would not use the second method alone.
IF you want to make cookies harder to guess, maybe you can combine them.
(init with System.currentTimeMillis and synchronously increase by a random but limited number ?)

first is fine from my point of view.
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hallo,


I have a prototype(I am working on URLyBird 1.3.3) where I use like key the recRo.

Question : why you need an unique number for each person ?

IMO if user X locks record R1 then the record R1 is lock and if an user Y try to acces it then he must wait until the record is free.I also check if the record was deleted every time when a client gains access to a record so if a client waits and in the meantime the record is deleted the client is informed.



Regards,

Mihai.
 
reply
    Bookmark Topic Watch Topic
  • New Topic