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.
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 ?)
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.