void removeUnconfirmedTransactions(Collection<TransactionImpl> transactions) {
   List<Transaction> removedList = new ArrayList<>();
   for (TransactionImpl transaction : transactions) {
     if (unconfirmedTransactions.remove(transaction.getId()) != null) {
       transaction.undoUnconfirmed();
       unconfirmedTransactionHashes.remove(transaction.getHash());
       removedList.add(transaction);
     }
   }
   transactionListeners.notify(removedList, Event.REMOVED_UNCONFIRMED_TRANSACTIONS);
 }
        @Override
        public void run() {

          try {
            try {

              int curTime = Convert.getEpochTime();
              List<Transaction> removedUnconfirmedTransactions = new ArrayList<>();

              synchronized (BlockchainImpl.getInstance()) {
                Iterator<TransactionImpl> iterator = unconfirmedTransactions.values().iterator();
                while (iterator.hasNext()) {
                  TransactionImpl transaction = iterator.next();
                  if (transaction.getExpiration() < curTime) {
                    iterator.remove();
                    unconfirmedTransactionHashes.remove(transaction.getHash());
                    transaction.undoUnconfirmed();
                    removedUnconfirmedTransactions.add(transaction);
                  }
                }
              }

              if (removedUnconfirmedTransactions.size() > 0) {
                transactionListeners.notify(
                    removedUnconfirmedTransactions, Event.REMOVED_UNCONFIRMED_TRANSACTIONS);
              }

            } catch (Exception e) {
              Logger.logDebugMessage("Error removing unconfirmed transactions", e);
            }
          } catch (Throwable t) {
            Logger.logMessage("CRITICAL ERROR. PLEASE REPORT TO THE DEVELOPERS.\n" + t.toString());
            t.printStackTrace();
            System.exit(1);
          }
        }