velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nick Bauman" <n...@cortexity.com>
Subject Re: Thread safety
Date Mon, 01 Oct 2001 20:58:10 GMT
> On 10/1/01 4:24 AM, "Bojan Smojver" <bojan@binarix.com> wrote:
> 
>> Are Template.merge() and VelocityEngine.getTemplate() thread safe?
>> 
>> Bojan
> 
> merge() is as long as you don't share a VelocityContext across
> simultaneous threads.

Which means the answer is "no" ;) 

You have really only 2 choices for the web:

 a) Create a new VelocityContext for each http request
 b) Pool VelocityContexts and recycle them. Since they already implement
clone() very nicely, this should be easy.

There is one more choice, but it's not a real one:

 c) serialize access to the context --  not really an option on the web


> getTemplate() should be as well.
> 
> Er, why?  Problems?
> 
> -- 
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> "Whoever would overthrow the liberty of a nation must begin by subduing
> the freeness of speech." - Benjamin Franklin



Mime
View raw message