//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMultipleCreate() throws InterruptedException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void TestMultipleCreate() { const int numThreads = 25; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String uuid = java.util.UUID.randomUUID().toString(); string uuid = System.Guid.randomUUID().ToString(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.graphdb.Node commonNode; Node commonNode; using (Transaction tx = _graphDb.beginTx()) { commonNode = _graphDb.createNode(); tx.Success(); } ExecutorCompletionService <Node> ecs = new ExecutorCompletionService <Node>(Executors.newFixedThreadPool(numThreads)); for (int i = 0; i < numThreads; i++) { ecs.submit(() => { using (Transaction tx = _graphDb.beginTx()) { Node node = _graphDb.createNode(); // Acquire lock tx.AcquireWriteLock(commonNode); Index <Node> index = _graphDb.index().forNodes("uuids"); Node existing = index.get("uuid", uuid).Single; if (existing != null) { throw new Exception("Node already exists"); } node.setProperty("uuid", uuid); index.add(node, "uuid", uuid); tx.Success(); return(node); } }); } int numSucceeded = 0; for (int i = 0; i < numThreads; i++) { try { ecs.take().get(); ++numSucceeded; } catch (ExecutionException) { } } assertEquals(1, numSucceeded); }
internal QueueingFuture(ExecutorCompletionService <V> outerInstance, RunnableFuture <V> task) : base(task, null) { this.OuterInstance = outerInstance; this.Task = task; }