[jdom-interest] Stack & Threads
jhunter at acm.org
Tue Mar 5 10:25:44 PST 2002
"David D. Lucas" wrote:
> I noticed in several classes JDOM uses Stack which is JDK 1.1 type that
> extends Vector. Seeing that no one is recommending use of JDOM between
> threads, is this a potential synchronization hotspot with the constant
> locking and unlocking when using the stack?
Good point on the synchronization! The only place I see Stack still
used is in SAXHandler to manage the SAX state. Do you see it
elsewhere? NamespaceStack is our own creation.
If you want to change SAXHandler to use an ArrayList instead of a Stack
and look for any build time improvement, that would be very useful.
> Is there a way to migrate over to JDK 1.2 collections and use the
> ArrayList instead?
Sure, we're using Java 2 collections everywhere else.
> Also, I noticed some thread access checking code in ContentList and
> wondered if it works or should even be there, again based on the
> comments that we should not be using JDOM between threads concurrently.
The concurrent modification checking follows the collections model with
"fail fast" behavior -- actions aren't synchronized, but you do get an
exception if the data you're relying on has been altered by another
More information about the jdom-interest