Code example for WeakHashMap

Methods: containsKeygetput

0
  } 
   
   
  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);
    l.lock();
    return result;
  } 
   
   
  private static class Unlocker implements Runnable {
    private final ReentrantLock _l;
Stop searching for code, let great code find you!  Add Codota to your java IDE