private boolean targetTxnsPresentInReplTxnMap(Long startTxnId, Long endTxnId, List<Long> targetTxnId) throws Exception {
    String[] output = TestTxnDbUtil.queryToString(conf, "SELECT \"RTM_TARGET_TXN_ID\" FROM \"REPL_TXN_MAP\" WHERE " +
            " \"RTM_SRC_TXN_ID\" >=  " + startTxnId + "AND \"RTM_SRC_TXN_ID\" <=  " + endTxnId).split("\n");
    List<Long> replayedTxns = new ArrayList<>();
    for (int idx = 1; idx < output.length; idx++) {
      replayedTxns.add(Long.parseLong(output[idx].trim()));
    }
    return replayedTxns.equals(targetTxnId);
  }
counter = 0;
Thread1 counter=1, lock, wait 3s, check counter(should be 2), counter=3, unlock
Thread2 counter=2, lock (and block), inc counter, should be 4
ql/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandler.java