File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLyBIRD lock question

 
Mark Waldrop
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Frans Janssen
Ranch Hand
Posts: 357
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Uwe Schäfer
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic