All I meant was that there's a similarity between a single Action instance 
having multiple threads comcurrently invoke its execute/perform method and a 
single Converter instance having multiple threads concurrently invoke its 
convert method. Same deal with a single HttpServlet instance having multiple 
threads concurrently invoke its doGet/doPost methods. In each case, you really 
want to keep static and instance fields that maintain state for a given method 
invocation out of the equation. If you do make use of those fields, you have to 
provide synchronization. The downside to synchronization is that it can impact 
throughput and potentially cause deadlock.

That being said, in general I'd recommend creating a new instance instead of 
introducing synchronization. The interesting twist with SimpleDateFormat is 
that there appears to be a reported issue with excessive String creation in the 
bug report that Antoni referenced (4228335). It looked like one of the 
reviewers couldn't reproduce the results, but it's something to keep in mind.

Quoting Rick Reumann <[EMAIL PROTECTED]>:

> 
> 
> On Wednesday, November 6, 2002, 4:31:09 PM, Kris wrote:
> 
> KS> The creation of the converters and their registration can
> KS> obviously be accomplished in a thread-safe manner, but if multiple
> KS> threads call into parse and/or format at the same time, this will
> KS> cause a problem. If that's not what Antoni was saying...it's still
> KS> a problem ;-). Shouldn't you code a Converter's convert method
> KS> with the same approach to thread-safety as an Action's
> KS> execute/perform method? If your Converter maintains a
> KS> SimpleDateFormat instance field that it uses to either format or
> KS> parse, it's not thread safe.
> 
>     Thank you as well Kris. I'm looking at the Struts Action
>     execute/perform methods and I'm not sure how the situation is the
>     same though. I'll look at them some more.
> 
>     Thanks guy for bringing this thread safe issue to my attention.
> 
> 
> 
> 
> -- 
> 
> Rick
> mailto:maillist@;reumann.net
> 
> 
> --
> To unsubscribe, e-mail:  
> <mailto:struts-user-unsubscribe@;jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@;jakarta.apache.org>
> 


-- 
Kris Schneider <mailto:kris@;dotech.com>
D.O.Tech       <http://www.dotech.com/>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to