Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

lockCookie

 
Jerry Ju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

It's the first time that I post a question which related with the lockCookie value, long type.

And I'm not a native English Speaker and Writer. ^^
I'm trying to do my best on writing correctly.
What If there is some missing in my message, please understand it. ~~

As I thought It has two possible value for lockCookie.
which are Thread.currentThread() and Calendar.getInstance().getTimeInMillis()

I used randomAccessFile and synchronized lockRecord method.
so timeInMills also possible. the Thread also unique value of each thread.

Am I right?

which one you guys using for lookie?

Thanks for regards.
[ September 10, 2008: Message edited by: Jerry Ju ]
 
Jevgeni Zhukov
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi and welcome to Javaranch!
I used

for lock cookie value.
 
Jerry Ju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your concern. I'll try it.
[ September 10, 2008: Message edited by: Jerry Ju ]
 
Alexandre Baldo
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used
...
 
kenjiro Emoto
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi and Welcom to JavaRanch!

I use this as well.


but a bit differently.

On every generateCookie() method invocation on LockManager class from synchronized region,
cookieValue is incremented by one, please look at the following codes.



p.s.
Chingu!
I'm also living in very close country, Japan.
[ September 15, 2008: Message edited by: kenjiro Emoto ]
 
Kah Tang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just created random long numbers using the Random class. It works quite well, I guess
 
Jerry Ju
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all guys who replayed on my post.

I'm gonna use System.nanoTime() instead of thread number.

At first random, depends on the range but has a possible to generate the same number. I think.

Second Thread Id also possible, but the number is small maybe 1~10.
and It is also reused when the thread dead and create new one. (but It also possible when your code is exactly locking and unlocking)

But I choose time. Although multi-thread try to get a cookieId at the same time, It is impossible to get the same cookie ID in synchronized method.

That's my reason.

Thanks again ~~ Wish me luck to get a cert. and I also wish you luck. ^^

P.S.

Hi TomoTazzy. ~~ ^^
It's great to see you.
[ September 15, 2008: Message edited by: Jerry Ju ]
 
Jethro Borsje
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using System.nantime() also, it seems to me like its the best choice, because it will be unique.
 
Marcus Park
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jerry, I live in Korea too. I've never seen a Korean posting on here, it's my first time though.
I use Random class for the long type cookie. It works quite well I guess.
I've almost done implementing URLyBird application, but I still doubt in so many things. To be honest, I'm afraid of preparing documentation. How hard it would be. nice to see you on this great community. Good luck..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic