Hi,
Originally posted by Shan Jun Hao:
Well, I think it's fine and can't think of any negative implications on this.
Personally I didn't like the 'Random' aspect of assigning a cookie as it is possible (though unlikely) that two cookies could be the same but associated with different records. Since my design uses a Map to store valid-cookie-to-recNo information I would run into trouble. You may be okay though.
I actually just went for using a long instance variable and just increment it each time I want a new lock cookie. I am guaranteed unique-ness of cookie then for what I consider to be the rest of time. For example, if my server has to deal with 1000 locks per second, I am effectively okay for about 600,000,000 years before cookie values wrap around with overflow. I doubt my server would still be up at that time, and if it is -- I'm pretty sure I won't be the one that gets the help-desk call at 6am in the morning.
Cheers, Jared.