My friend suggested concatenating the recNo with the current time. Sounds like a good idea to me.
SCJP 1.4, SCJD 1.4, SCBCD (Preparing!)
Satish Avadhanam
Ranch Hand
Joined: Aug 12, 2003
Posts: 697
posted
0
Hi Min
Originally posted by Min Huang: My friend suggested concatenating the recNo with the current time. Sounds like a good idea to me.
If you have time, you might want to take a look at the following thread Lock question Good Luck.
Xie Ruchang
Ranch Hand
Joined: Dec 25, 2003
Posts: 160
posted
0
Read this thread Lock Cookie Generation. Bear in mind, the time can be the same for two consecutive locks due the the granularity of the system time update. So if you generate the cookie based on what you have suggested, you will run into problems by having two identical locks!
Bigwood Liu
Ranch Hand
Joined: Feb 26, 2003
Posts: 240
posted
0
Hi, use a unique Random Damu
Michael Hartman
Greenhorn
Joined: Feb 01, 2004
Posts: 11
posted
0
I used a static long and simply increment it from a synchronized method. For example,
...
Satish Avadhanam
Ranch Hand
Joined: Aug 12, 2003
Posts: 697
posted
0
Hi Michael, if you want to have new ideas of generating a lock cookie then you really want to read the link I have given before. In that Phil clearly explained what we can use as a lock cookie and what not. Good Luck. BTW, forgot to say. Welcome to JavaRanch and SCJD forum
Xie Ruchang
Ranch Hand
Joined: Dec 25, 2003
Posts: 160
posted
0
Hi Michael, Welcome to the forum! Your method works well! Many people prefer the random approach. I prefer the time approach because it can be used by the server to timeout the locks, in the event a client crashed. Best Regards, Frankie