//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_RUN_TIME_MS * 20) public void closeTransaction() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CloseTransaction()
        {
            BlockingQueue <bool>             committerToTerminator = new LinkedBlockingQueue <bool>(1);
            BlockingQueue <TerminatorAction> terminatorToCommitter = new LinkedBlockingQueue <TerminatorAction>(1);

            RunTwoThreads(tx =>
            {
                bool?terminatorShouldAct = committerToTerminator.poll();
                if (terminatorShouldAct != null && terminatorShouldAct)
                {
                    TerminatorAction action = TerminatorAction.random();
                    action.executeOn(tx);
                    assertTrue(terminatorToCommitter.add(action));
                }
            }, tx =>
            {
                tx.initialize();
                CommitterAction committerAction = CommitterAction.random();
                committerAction.executeOn(tx);
                if (committerToTerminator.offer(true))
                {
                    TerminatorAction terminatorAction;
                    try
                    {
                        terminatorAction = terminatorToCommitter.poll(1, TimeUnit.SECONDS);
                    }
                    catch (InterruptedException)
                    {
                        Thread.CurrentThread.Interrupt();
                        return;
                    }
                    if (terminatorAction != null)
                    {
                        Close(tx, committerAction, terminatorAction);
                    }
                }
            });
        }
 private static void Close(TestKernelTransaction tx, CommitterAction committer, TerminatorAction terminator)
 {
     try
     {
         if (terminator == TerminatorAction.None)
         {
             committer.closeNotTerminated(tx);
         }
         else
         {
             committer.closeTerminated(tx);
         }
     }
     catch (TransactionFailureException e)
     {
         throw new Exception(e);
     }
 }