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

Jools Enticknap jools at jools.org
Fri Sep 22 09:25:47 PDT 2000

> > 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 ?

One approach might be to have separate classloaders for each 'read' 
thread. That way there would be more than one static namespace hash,
and no need to synchronize it internally.


More information about the jdom-interest mailing list