[jdom-interest] static data needs to be thread data for mul tithreaded applications

Nick Reeves Nick.Reeves at gtl.com
Fri Sep 22 09:57:35 PDT 2000

The class could either keep the last Namespace returned or an array of
recently returned
ones indexed by abs(key.hashCode() % length), and only go onto doing the
full version involving syncronization if this failed.

> > > The actual patch is trivial it's just a matter of add a
> > > synchronized block in getNamespace as marked with ++ below,
> > > and some suitable comments on synch policy.
> > 
> > That's the easy way.  :-)  But I was wondering if there could be an
> > optimization (it's important here, this code is called all 
> the time).
> > Like for example you could put "if not contains then add" 
> in the sync
> > block and handle the return and the corresponding hash 
> lookup outside
> > the block.  That'd shorten the crit section.
> Before we go down this path, I'd like to see some benchmarks, and some
> more reasoning.
> Also, is there an external way of resolving this problem 
> without having
> to resort to putting synchronization into the code API ?

More information about the jdom-interest mailing list