public Map<K, Lock> acquireLocks(Set<? extends K> keys) {
    Object[] keyArray = keys.toArray();
    Arrays.sort(keyArray);

    lockPool.purge();
    Map<K, Lock> locks = new LinkedHashMap<>(keyArray.length);
    for (Object o : keyArray) {
      @SuppressWarnings("unchecked")
      K key = (K) o;
      ReentrantLock lock = lockPool.get(key);
      locks.put(key, lock);
    }

    for (Lock lock : locks.values()) {
      lock.lock();
    }
    return locks;
  }
Acquire locks for a set of keys. The keys will be sorted internally to avoid possible deadlock.
@throws ClassCastException if the given {@code keys} contains elements that are not mutually
                           comparable
hbase-common/src/main/java/org/apache/hadoop/hbase/util/KeyLocker.java