my dog learned polymorphism*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "URLyBIRD lock question" Watch "URLyBIRD lock question" New topic
Author

URLyBIRD lock question

Mark Waldrop
Greenhorn

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?

Thanks,
Mark
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.

Frans.


SCJP 1.4, SCJD
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.


scja|scjp|scjd|scwcd|scbcd|scdjws|scmad
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

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.


SCJP, SCJD, SCWCD, OCPJBCD
 
 
subject: URLyBIRD lock question
 
Similar Threads
URLybird
URLyBird - Locking "Catch 22"
NX: URLyBird 1.1.3
URLyBird Locking
URLyBird Question