private void removeLocksAndUnblock(Transaction transaction, 
      long timestamp) {
    Set<String> variables = lockManager.endTransaction(transaction);
    transactionMap.remove(transaction.getName());
    for(LinkedHashMap<Transaction, Lock> transactionLockMap 
        : blockedTransactions.values() ) {
      transactionLockMap.remove(transaction);
    }
    
    for( Map.Entry<String, LinkedHashMap<Transaction, Lock>> blockedTranEntry 
        : blockedTransactions.entrySet() ) {
      LinkedHashMap<Transaction, Lock> transactionLockMap = blockedTranEntry
          .getValue();
      String variable = blockedTranEntry.getKey();
      if( variables.contains(variable) ) {
        Iterator<Map.Entry<Transaction, Lock>> iterator 
            = transactionLockMap.entrySet().iterator();
        if( iterator.hasNext() ) 
        {
          Map.Entry<Transaction, Lock> entry = iterator.next();
          Transaction blockedTransaction = entry.getKey();
          Lock lock = entry.getValue();
          iterator.remove();
          if( lock.getType() == Lock.Type.READ ) {
            read(blockedTransaction.getName(), variable, timestamp);
          }
          else if( lock.getType() == Lock.Type.WRITE ) {
            write(blockedTransaction.getName(), variable, 
                lock.getWriteOperation().getNewValue(), timestamp);
          }
        }
      }
    }
  }