Package java.lang.ref

Examples of java.lang.ref.SoftReference.clear()


                if (ref != null) {
                    loader = (Loader) ref.get();
                    if (loader != null && loader.isValid()) {
                        break getLoader;
                    }
                    ref.clear();
                }
                loader = parent == null ? new Loader() : new Loader(parent);
                cLoaders.put(parent, new SoftReference(loader));
            }
View Full Code Here


     * Flushes the cached object.  Forces the next invocation of get() to
     * invoke reconstitute().
     */
    public synchronized void flush() {
        SoftReference s = soft;
        if (s != null) s.clear();
        soft = null;
    }

    /**
     * Sets the thing to the specified object.
View Full Code Here

    tmpB = new Object();
    SoftReference sr = new SoftReference(tmpA, new ReferenceQueue());
    WeakReference wr = new WeakReference(tmpB, new ReferenceQueue());
    assertTrue("Start: Object not cleared.", (sr.get() != null)
        && (wr.get() != null));
    sr.clear();
    wr.clear();
    assertTrue("End: Object cleared.", (sr.get() == null)
        && (wr.get() == null));
    // Must reference tmpA and tmpB so the jit does not optimize them away
    assertTrue("should always pass", tmpA != sr.get() && tmpB != wr.get());
View Full Code Here

                    obj = _factory.makeObject();
                }
            } else {
                SoftReference ref = (SoftReference)(_pool.remove(_pool.size() - 1));
                obj = ref.get();
                ref.clear(); // prevent this ref from being enqueued with refQueue.
            }
            if (null != _factory && null != obj) {
                try {
                    _factory.activateObject(obj);
                    if (!_factory.validateObject(obj)) {
View Full Code Here

                    obj = _factory.makeObject();
                }
            } else {
                SoftReference ref = (SoftReference)(_pool.remove(_pool.size() - 1));
                obj = ref.get();
                ref.clear(); // prevent this ref from being enqueued with refQueue.
            }
            if (null != _factory && null != obj) {
                try {
                    _factory.activateObject(obj);
                    if (!_factory.validateObject(obj)) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.