Code example for WeakHashMap

Methods: containsKeygetput

  public synchronized ReentrantLock get(T val) {
    IdentityWrapper<T> key = IdentityWrapper.make(val);
    if (!_map.containsKey(key)) { _map.put(key, new ReentrantLock()); }
    return _map.get(key);
  public Runnable lock(T val) {
    final ReentrantLock l = get(val);
    Runnable result = new Unlocker(l);
    return result;
  private static class Unlocker implements Runnable {
    private final ReentrantLock _l;
Connect your IDE to all the code out there  Get Codota for Java