ThreadedTransactionalGraph extends TransactionalGraph by an additional method that returns a TransactionalGraph identifying a thread-independent transactional object. This is in contrast to TransactionalGraph where transactions are always tied to the thread operating on the graph.
So, what this allows you to do is something like the following.
ThreadedTransactionalGraph g = new ...
TransactionalGraph transaction = g.startThreadTransaction() //we get a transaction object that is independent from the current thread
for (Vertex marko : transaction.getVertices("name","Marko")) {
Thread particle = new ParticleSwarm(transaction,marko);
particle.run();
}
//Collect all the results from the individual particles for a particular analysis
This code snippet is just for demonstration purposes and illustrates a scenario, where you want to have multiple particles traverse a graph starting from all the vertices named "Marko" for some sort of analysis and then collect the results. To speed up the analysis, we run each particle in a separate thread. In TransactionalGraph, each of these threads would run in a separate transaction, which is not what we want here (in particular if the particle modifies the graph in any way).
Now, while this is a more "advanced" application of transactions, it will be a very important one in the near future. A lot of graph algorithms are pretty expensive (e.g. extensive traversals) but easily parallelizable. As raw CPU performance won't be increasing much but many more cores will be added, multi-threaded approaches (such as the trivial one outlined above) are the only way to speed up such algorithms. ThreadedTransactionalGraph provides transactional support for multi-threaded algorithms.
Cheers,
Matthias