private int selectLock(final Object key, int numberOfLocks) {
        int number = numberOfLocks & (numberOfLocks - 1);
        if (number != 0) {
            throw new RuntimeException("Lock number must be a power of two: " + numberOfLocks);
        }
        if (key == null) {
            return 0;
        } else {
            int hash = hash(key) & (numberOfLocks - 1);
            return hash;
        }
    }
Selects a lock for a key. The same lock is always used for a given key.
stroom-util/src/main/java/stroom/util/concurrent/StripedLock.java