[stringtemplate-interest] ST in multi-threaded environment
Terence Parr
parrt at cs.usfca.edu
Mon Jul 10 11:00:12 PDT 2006
On Jul 9, 2006, at 11:37 PM, Oliver Flege wrote:
> Hi,
>
> David Moshal wrote:
>> agreed, besides, thread-safety comes with a performance penalty.
> of course, but compared to the rendering a complete web-page, the
> required synchronization cost would be marginal (less than 1% I'd
> guess).
> Besides, if you use a program in a multi-threaded environment, you
> just
> don't have a choice: either it's thread-safe or it will break
> (sooner or
> later) (see: "Java Concurrency in Practice" by Brian Goetz)
The surest way to create deadlock is to make everything "threadsafe"
by putting synchronized everywhere. ;) Not that that is what you
are suggesting, but one must be careful...
ST cannot change values and so multi-threads are free to create
multiple instances at any time. jGuru does this as do all my other
sites. No problem. Only problem you have is when your data
structures change out from underneath ST, which it cannot prevent.
You can choose to pass in Vector not ArrayList and that should solve
that problem. i create ArrayList objects for multi-attributes, but
you don't have a ptr to it and can't muck with it.
I don't think we have a threading issue...can somebody point out a
scenario? I'd be very happy to address it in the code or at least
doc ;)
Ter
More information about the stringtemplate-interest
mailing list