我正在使用来自 maven 存储库的 blueprints-neo4j-graph-2.5.0。
在使用来自不同线程的图表时,neo4j 冻结。重新创建问题的代码,并附加了调用堆栈。任何有关此的解决方案或任何使用模式将不胜感激。
public class Simplest {
public static void main(String[] args) {
new Simplest();
}
Graph g = new Neo4jGraph("E:/temp/neoTest");
Vertex a = g.addVertex(null);
public Simplest() {
new Thread(new Runnable() {
@Override
public void run() {
Vertex b = g.addVertex(null);
a.addEdge("relation", b);
System.out.println("never reaches here...");
}
}).start();
}
}
堆栈跟踪如下...
Thread [Thread-2] (Suspended)
waiting for: RWLock (id=43)
Object.wait(long) line: not available [native method]
RWLock(Object).wait() line: 503
RWLock.deadlockGuardedWait(Transaction, RWLock$TxLockElement, LockType) line: 652
RWLock.acquireWriteLock(Transaction) line: 344
LockManagerImpl.getWriteLock(Object, Transaction) line: 84
LockManagerImpl.getWriteLock(Object) line: 77
WritableTransactionState.acquireWriteLock(Object) line: 269
LockType$2.acquire(TransactionState, Object) line: 51
NodeManager.getNodeForProxy(long, LockType) line: 473
InternalAbstractGraphDatabase$8.lookup(long, LockType) line: 791
NodeProxy.createRelationshipTo(Node, RelationshipType) line: 207
Neo4jGraph.addEdge(Object, Vertex, Vertex, String) line: 487
Neo4jVertex.addEdge(String, Vertex) line: 47
Simplest$1.run() line: 24
Thread.run() line: not available