[jdom-interest] Thread safe question: OK for simultaneous read-only access?
bob at werken.com
Sun Oct 28 08:45:29 PST 2001
> > Do you mean the Element level?
> > The only problem I see with that is, given:
> > <a>
> > <b>
> > <c/>
> > </b>
> > </a>
> > If one thread is processing <c>, and another takes <b>, and removes
> > it from the document altogether, then where does that leave the guy
> > processing <c>?
> Does he really care? His view is at <c> and it's descendents.
The kicker is that he *might not* be only concerned with descendants.
What if he's somehow attempting to get the path-to-root, using
something like elemC.getParent()?
Or, if you have a depth-first traversal going, and <b> has siblings,
and you're processing <c>, and it's parent <b> has been removed,
you're now traversing the document and the removed fragment at
the same time (if the Collection holding <a>'s children doesn't
throw some exception at you).
Thus, I argue, the only 'safe' lock that keeps folks out of
trouble is the large-grained Document-centric lock. Hence,
it's best to leave synchronization semantics entirely to the
More information about the jdom-interest