public class a {
private static TitanGraph titanGraph = null;
static GraphTraversalSource traversalSource = null;
public static void main(String a[])
{
titanGraph = TitanFunctions.getTitanGraph();
traversalSource = titanGraph.traversal();
// Task to be executed by each thread
Runnable r = new Runnable() {
public void run() {
long ab = traversalSource.V().has("RequestJob", "RequestId", 203)
.has("JobLockStatus","F")
.property("JobLockStatus", "B").count().next();
titanGraph.tx().commit();
System.out.println("value: "+ab+" : " +Thread.currentThread().getName());
}
};
Thread t1 = new Thread(r, "T1");
Thread t2 = new Thread(r, "T2");
t1.start();
t2.start();
}}
In the above program, Two concurrent threads are trying to update the value..from “F” to “B” for the same RequestId=203
.
It seems like both threads are getting the status value as “F” and updating it to B.
But I want only one thread should change the value from “F” to “B”. After updating the value , I have used commit() also to save the changes.
If any thread changed the status from “(F)ree” to “(B)usy”..and other thread should see the changed value..(“B”).
Kindly help me to resolve this.