public void releaseCapacity(int capacityToRelease){
  if (capacityToRelease <= 0) {
    return;
  }
  List<Ticket> parentTicketsToRelease=new ArrayList<>();
  mLock.lock();
  try {
    if (capacityToRelease > mCapacity) {
      capacityToRelease=mCapacity;
    }
    mCapacity-=capacityToRelease;
    int numParentTicketsToRelease=Math.min(mParentTickets.size(),capacityToRelease);
    for (int i=0; i < numParentTicketsToRelease; i++) {
      parentTicketsToRelease.add(mParentTickets.remove());
    }
    abortWaitersOnCapacityDecrease();
  }
  finally {
    mLock.unlock();
  }
  for (  Ticket ticket : parentTicketsToRelease) {
    ticket.close();
  }
  updateCurrentTicketCount();
}

public void releaseCapacity ( int capacityToRelease ) { if ( capacityToRelease <= 0 ) { return ; } List < Ticket > parentTicketsToRelease = new ArrayList < > ( ) ; mLock . lock ( ) ; try { if ( capacityToRelease > mCapacity ) { capacityToRelease = mCapacity ; } mCapacity -= capacityToRelease ; int numParentTicketsToRelease = Math . min ( mParentTickets . size ( ) , capacityToRelease ) ; for ( int i = 0 ; i < numParentTicketsToRelease ; i ++ ) { parentTicketsToRelease . add ( mParentTickets . remove ( ) ) ; } abortWaitersOnCapacityDecrease ( ) ; } finally { mLock . unlock ( ) ; } for ( Ticket ticket : parentTicketsToRelease ) { ticket . close ( ) ; } updateCurrentTicketCount ( ) ; }
releases the capacity to the parent ticket pool . note that the tickets will be released as soon as possible . however , this is not necessarily immediately if there are tickets which have been acquired ( ) by a user of this class , but not yet released .
