You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@clerezza.apache.org by Reto Bachmann-Gmuer <re...@trialox.org> on 2011/03/27 08:28:43 UTC

FAQ on website: Is the RDF API thread-safe?

Apparently with the styling of the website, also the claim that the
Clerezza RDF is not thread safe has been added to the FAQ.

The correct answer to this is:
All MGraphs returned by TcManager are LockableMgraphs, this graphs are
thread-safe independently on whether the underlying provider is
thread-safe or not. Note however that like the synchronized
collections returned by java.util.Collections a
ConcurrentModificationException may occur when the TripleCollection is
modified while iterating over it. To be sure that no other thread may
do any modification while iterating over it, the iterating thread may
acquire a ReadLock using the following construct:

Lock l = mGraph.getLock().readLock();
l.lock();
try {
 Iterator<Triple> iter = mGraph.filter(...);
 //iterate over triples
} finally {
l.unlock();
}

I'll change the FAQ.

Cheers,
Reto