public synchronized void flushTargets(boolean force) {
        Iterator<Entry> it = targets.values().iterator();
        long currentTime = timer.milliTime();
        long expireTime = currentTime - expireMillis;
        while (it.hasNext()) {
            Entry entry = it.next();
            if (entry.isValid()) {
                if (entry.getRefCount() > 1) {
                    entry.lastUse = currentTime;
                    continue; // someone is using this
                }
                if (!force) {
                    if (entry.lastUse > expireTime) {
                        continue; // not sufficiently idle
                    }
                }
            }
            entry.close();
            it.remove();
        }
    }
Closes all unused target connections. Unless the force argument is true, this method will allow a grace period
for all connections after last use before it starts closing them. This allows the most recently used connections
to stay open.

@param force Whether or not to force flush.
messagebus/src/main/java/com/yahoo/messagebus/network/rpc/RPCTargetPool.java