1 package com.quadcap.sql.lock; 2 3 40 41 import java.util.HashMap ; 42 43 import java.lang.ref.SoftReference ; 44 45 import com.quadcap.util.Debug; 46 47 52 public class LockPool { 53 HashMap locks = new HashMap (); 54 55 public LockPool() { 56 } 57 58 public final Lock get(Lock parent, String name) { 59 SoftReference ref = (SoftReference )locks.get(name); 60 Lock lock = null; 61 if (ref != null) { 62 Object obj = ref.get(); 63 if (obj != null) { 64 lock = (Lock)obj; 65 } else { 66 locks.remove(name); } 68 } 69 if (lock == null) { 70 lock = new Lock(); 71 lock.init(parent, name); 72 ref = new SoftReference (lock); 73 locks.put(name, ref); 74 } 75 return lock; 76 } 77 } 78 | Popular Tags |