Using the following as a template for multithreading....

public class ConcurrencyTest {
    private OrientGraphFactory factory;
    @Before
    public void setup() {

        factory = new OrientGraphFactory("memory:test");
    }
    @Test
    public void testConcurrentAccess() {
        ExecutorService executor = Executors.newFixedThreadPool(5);
        for (int i = 0; i < 1; i++) {
            Runnable worker = new MyThread(factory);
            executor.execute(worker);
        }
        executor.shutdown();
        while (!executor.isTerminated()) {
        }
    }
    public static class MyThread implements Runnable {
        private TransactionalGraph graph;
        public MyThread(OrientGraphFactory factory) {
            this.graph = factory.getTx();
        }
        @Override
        public void run() {
            graph.getFeatures();
            Iterable<Vertex> vertices = graph.getVertices();
            long count = 0;
            for (Vertex v : vertices) {
                count++;
            }
            System.out.println("Found " + count + " vertices");
        }
    }
}

Is it necessary to call graph.shutdown() ?

I understood that this would release the connection back to the factory 
pool....

I tried putting it at the end of run but it seemed to cause memory to 
massively climb....

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to