Package java.lang.ref

Examples of java.lang.ref.SoftReference


        }

        boolean shouldDestroy = !success;
        _numActive--;
        if(success) {
            _pool.add(new SoftReference(obj, refQueue));
        }
        notifyAll(); // _numActive has changed

        if (shouldDestroy && _factory != null) {
            try {
View Full Code Here


            _factory.passivateObject(obj);
        }

        boolean shouldDestroy = !success;
        if(success) {
            _pool.add(new SoftReference(obj, refQueue));
            notifyAll(); // _numActive has changed
        }

        if(shouldDestroy) {
            try {
View Full Code Here

        }
        if (formatter == null) {
            // No cache yet, or cached formatter GC'd
            formatter = new SimpleDateFormat(NTP_DATE_FORMAT, Locale.US);
            formatter.setTimeZone(TimeZone.getDefault());
            simpleFormatter = new SoftReference(formatter);
        }
        Date ntpDate = getDate();
        synchronized (formatter) {
            return formatter.format(ntpDate);
        }
View Full Code Here

        if (formatter == null) {
            // No cache yet, or cached formatter GC'd
            formatter = new SimpleDateFormat(NTP_DATE_FORMAT + " 'UTC'",
                    Locale.US);
            formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
            utcFormatter = new SoftReference(formatter);
        }
        Date ntpDate = getDate();
        synchronized (formatter) {
            return formatter.format(ntpDate);
        }
View Full Code Here

    private Expression compileExpression(String xpath) {
        Expression expr;
        if (USE_SOFT_CACHE) {
            expr = null;
            SoftReference ref = (SoftReference) compiled.get(xpath);
            if (ref != null) {
                expr = (Expression) ref.get();
            }
            if (expr == null) {
                expr =
                    (Expression) Parser.parseExpression(xpath, getCompiler());
                compiled.put(xpath, new SoftReference(expr));
                if (cleanupCount++ >= CLEANUP_THRESHOLD) {
                    cleanupCache();
                }
            }
        }
View Full Code Here

        default:
            throw new UnsupportedOperationException("Unsupported Data Type");

        }

        return new SoftReference(array);
    }
View Full Code Here

            Object value = recycledArrays.get(key);

            if(value != null) {
                ArrayList arrays = (ArrayList)value;
                for(int idx = arrays.size() - 1; idx >= 0; idx--) {
                    SoftReference bankRef = (SoftReference)arrays.remove(idx);
                    memoryUsed -= getDataBankSize(arrayType,
                                                  (int)numBanks,
                                                  (int)arrayLength);
                    if(idx == 0) {
                        recycledArrays.remove(key);
                    }

                    Object array = bankRef.get();
                    if(array != null) {
                        return array;
                    }

                    if(DEBUG) System.out.println("null reference");
View Full Code Here

            throw new UnsupportedOperationException
                (JaiI18N.getString("Generic3"));

        }

        return new SoftReference(array);
    }
View Full Code Here

            Object value = recycledArrays.get(key);

            if(value != null) {
                ArrayList arrays = (ArrayList)value;
                for(int idx = arrays.size() - 1; idx >= 0; idx--) {
                    SoftReference bankRef = (SoftReference)arrays.remove(idx);
                    memoryUsed -= getDataBankSize(arrayType,
                                                  (int)numBanks,
                                                  (int)arrayLength);
                    if(idx == 0) {
                        recycledArrays.remove(key);
                    }

                    Object array = bankRef.get();
                    if(array != null) {
                        return array;
                    }

                    if(DEBUG) System.out.println("null reference");
View Full Code Here

  if (softRef == null ||
            ((colorConvertOpBuf = (HashMap)softRef.get()) == null)) {

      colorConvertOpBuf = new HashMap();
      softRef = new SoftReference(colorConvertOpBuf);
  }

  ArrayList hashcode = new ArrayList(2);
  hashcode.add(0, src);
  hashcode.add(1, dst);
View Full Code Here

TOP

Related Classes of java.lang.ref.SoftReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.