aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes lockCookie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "lockCookie" Watch "lockCookie" New topic
Author

lockCookie

Jerry Ju
Greenhorn

Joined: May 26, 2008
Posts: 7
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 ]

Primary Java Developer.<br /> <br />Living in Korea. I hope to meet lots of friends over the internet.<br /> <br />Thanks for all guys in this site who helped me to get a SCJD. <br />Cheers !
Jevgeni Zhukov
Greenhorn

Joined: Aug 28, 2008
Posts: 18
Hi and welcome to Javaranch!
I used

for lock cookie value.


SCJP<br />SCJD
Jerry Ju
Greenhorn

Joined: May 26, 2008
Posts: 7
Thanks for your concern. I'll try it.
[ September 10, 2008: Message edited by: Jerry Ju ]
Alexandre Baldo
Ranch Hand

Joined: Aug 04, 2006
Posts: 48
I used
...


...ops!<br>-----------------<br>
SCJD<br>
SCWCD 1.4<br>
SCJP 1.4
kenjiro Emoto
Greenhorn

Joined: Sep 10, 2008
Posts: 4
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

Joined: Sep 10, 2007
Posts: 58
I just created random long numbers using the Random class. It works quite well, I guess
Jerry Ju
Greenhorn

Joined: May 26, 2008
Posts: 7
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

Joined: Jul 22, 2008
Posts: 100
I am using System.nantime() also, it seems to me like its the best choice, because it will be unique.


SCJP, SCJD
Marcus Park
Greenhorn

Joined: Sep 20, 2008
Posts: 4
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..


SCJD
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: lockCookie