> From: lightbulb432 [mailto:[EMAIL PROTECTED] 
> Subject: RE: Is ThreadLocal safe to use in servlets
> 
> Is it safe to assume that this is the way to go, or are 
> there ever, ever any times when it would be less desirable
> to go this route than the default thread-pool-per-connector
> element?

I would expect there to be some additional CPU overhead with a shared
thread pool, but I have no idea what the magnitude of the difference
would be.  There should be reduced memory impact with a shared pool, but
you'd probably have to measure in your environment to see what the
effects really are.

Note that Remy M currently recommends against using an <Executor>:
http://marc.info/?l=tomcat-user&m=118002259402411&w=2

> Also, using this method can threads only be shared between
> Connectors associated with a single Engine (because Executor
> is a child of Service, not Server), rather than being shared
> between every request to all web applications on this instance
> of Tomcat?

Correct; there's virutally nothing sharable across <Service> elements.

> I have another question about using ThreadLocal as an 
> instance variable in a threadsafe Singleton. If the
> Singleton has 5 instance methods, each of which
> requires use of the value stored in the ThreadLocal

It's not clear to me why ThreadLocal would be advantageous here.  Sounds
like you really want a method-local variable, regardless of what thread
is using the particular method.  I don't really understand what problem
you're trying to solve here.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to