tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: where should i store a attribute
Date Fri, 31 Oct 2003 13:14:35 GMT

>> Hello folks, i´m trying to store a database connection in a session
>> attribute or request attribute, but i must choose a name that just
>> one thread per time would knowns. Any idea?

> I´m not sure if I understand your question, but hey, I´ll give it a
> shot:
> To get a unique name:
> String uniqueName = String.valueOf(System.currentTimeMillis());
> This will give you unique name. Check out the jdk-javadoc for an 
> explanation of this method.

I would not use System.currentTimeMillis, since it might not actually be 
unique, and its resolution is different on various platrofmr (i.e. 
Windows has only like a 10 or 100ms resolution, while Linux has 1000ms 

If you're looking for something unique to the Thread, why not use the 
thread's hashcode?

String uniqueName = String.valueOf(Thread.currentThread().hashCode());


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message