File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLyBIRD lock question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "URLyBIRD lock question" Watch "URLyBIRD lock question" New topic

URLyBIRD lock question

Mark Waldrop

Joined: Jan 04, 2004
Posts: 9
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?

Frans Janssen
Ranch Hand

Joined: Dec 29, 2004
Posts: 357
Hi Mark,

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


Uwe Schäfer
Ranch Hand

Joined: Mar 15, 2005
Posts: 52
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

Joined: Sep 18, 2003
Posts: 918


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.



I agree. Here's the link:
subject: URLyBIRD lock question
It's not a secret anymore!