velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Reck <Christoph.R...@dlr.de>
Subject Re: Thread safety
Date Tue, 02 Oct 2001 08:44:08 GMT
David Esposito wrote:
>[snip]
> Well, what i'm actually referring to is creating a my defaultContext inside
> of my Servlet init() method. Which, i believe (but wouldn't swear to without
> reading the spec), is guaranteed to execute before any of attempt to "use"
> the context via the doPost/doGet  ... The objects I stick in there are, as
> you suggest, immutable ... examples include:
> 
> - list of states
> - list of countries
> - "tool" objects that contain formatting functions (static methods) ...
> 
> etc ...
> 
> so it sounds like, in my particular case, sharing a velocity context across
> threads is safe ..

Be careful here, since VelociMacros and foreach loops will write to the
context. Therefore sharing a context over threads is not recommendable.

Use a chainged VC over the static one in the case you whant to use 
a pre-initialized one over multiple threads.

> 
> phew ... dodged a bullet there ... ;)
> 
> -Dave

:) Christoph

Mime
View raw message