Code example for ReferenceQueue

0
    private final MruEntry softHead = new MruEntry();
    { 
        softHead.linkAfter(strongHead);
    } 
    private final Map map = new HashMap();
    private final ReferenceQueue refQueue = new ReferenceQueue();
    private final int maxStrongSize;
    private final int maxSoftSize;
    private int strongSize = 0;
    private int softSize = 0;
     
    /** 
     * Creates a new MRU cache storage with specified maximum cache sizes. Each 
     * cache size can vary between 0 and {@link Integer#MAX_VALUE}. 
     * @param maxStrongSize the maximum number of strongly referenced templates 
     * @param maxSoftSize the maximum number of softly referenced templates 
     */ 
    public MruCacheStorage(int maxStrongSize, int maxSoftSize) {
        if(maxStrongSize < 0) throw new IllegalArgumentException("maxStrongSize < 0");
        if(maxSoftSize < 0) throw new IllegalArgumentException("maxSoftSize < 0");
        this.maxStrongSize = maxStrongSize;