[jdom-interest] Re: JDOM thread safety

Jason Hunter jhunter at acm.org
Sun Aug 13 16:48:30 PDT 2000


Joseph Bowbeer wrote:
> As a policy, it seems reasonable to me to decide that the
> behind-the-scenes changes should be synchronized by JDOM, and that
> synchronization of the other changes should be the responsibility
> of the user.

I agree, although I'd say "synchronized when necessary" -- and with a
quick glance through the current code base I didn't see a place where it
was necessary.  There are places where we could calculate the value to
be cached twice, but that's no harm done except wasted effort, and
overall I'm sure you get better performance by allowing that relatively
rare race condition and avoiding sync blocks.

We should, imho, keep this in mind when writing any future caching logic
though.  Another thing to keep in mind is that cache vars should
probably be held as weak references, but maybe we should hold off on
that until we're ready to fully abandon JDK 1.1 support.  It's an
implementation detail, after all.

-jh-



More information about the jdom-interest mailing list