commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: [lang] FastNumberFormat?
Date Wed, 11 Aug 2004 05:10:22 GMT
On Tue, 10 Aug 2004 20:10:46 -0700, Martin Cooper <mfncooper@gmail.com> wrote:
> On Tue, 10 Aug 2004 17:27:30 -0400, Gary Gregory
> <ggregory@seagullsoftware.com> wrote:
> > Why not give each thread its own DecimalFormat instance in a thread
> > local variable? Then you do not have to worry about it.
> 
> That's most likely what I'll end up doing. I was just hoping to get
> rid of synchronisation altogether, including the lock checks.
> 

You might want to review how ThreadLocal variables are implemented,
though ... it's most likely to be some sort of HashMap keyed by
classloader, and the get/put operations to update your thread's local
copy are likely to be synchronized internally.

The best way to avoid synchronization is likely to create one in a
local variable, then pass it around to whomever needs it.  Ugly, but
performance hacks are sometimes like that.

> --
> Martin Cooper

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message