• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Generate Cookie Value

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
What is the best way to generate the cookie value used when locking a record? I have read that some people suggest using the time however I was thinking of generating a random number.
Thanks
Chris
 
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Random is the class you need to look at.
Tony
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tony,
Thanks, I just wanted to check that there was not a 'special' way of genarating cookie values that I did not know about.
Chris
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am genarating the cookie value using the Random class. However I have noticed a small problem. If two threads attempt to lock two diffrent records (at the same time) they end up with the same cookie value. I am putting this down to the fact that Random uses the System time as a seed. Can any one suggest a way of getting around this?
Thanks
Chris
[ September 27, 2003: Message edited by: Chris Harris ]
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
To get around the timing issue when genarating a random cookie value I have done :

instead of:

I have read that my new way is slower but i can not get the Random class to do what i want. What do you think?
Chris
 
reply
    Bookmark Topic Watch Topic
  • New Topic