velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Thread safety
Date Mon, 01 Oct 2001 22:46:17 GMT
Man, look what the cat dragged in :)

On 10/1/01 5:23 PM, "Brian Goetz" <brian@quiotix.com> wrote:

> 
>>> merge() is as long as you don't share a VelocityContext across
>>> simultaneous threads.
>> 
>> Which means the answer is "no" ;)
> 
> Actually, I would say that this characterization is true but
> misleading.  The VelocityContext operations are explicitly not thread-safe,
> but merge() and friends are (according to Geir, I've not checked)
> thread-safe except to the extent that they use the VC.  While according to
> a dictionary definition, you might characterize this as being not
> thread-safe, in reality, as long as you are using VC properly (not sharing
> it across threads), then merge() and friends do not require additional
> synchronization.
> 

And again, it should only be with the VelocityContext class specifically.
This was done for convenience and efficiency for the most common usage.

Geir

>>  b) Pool VelocityContexts and recycle them. Since they already implement
>> clone() very nicely, this should be easy.
> 
> This is what WM does.  The Broker creates a Context at startup, and
> populates a pool using clone().  Alternately, you could use ThreadLocal to
> keep one around for each thread.

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



Mime
View raw message