Package java.lang.ref

Examples of java.lang.ref.ReferenceQueue


     * Clears the table.
     */
    public void clear() {
        table = new Entry[INITIAL_CAPACITY];
        count = 0;
        referenceQueue = new ReferenceQueue();
    }
View Full Code Here


    public static ReferenceQueue getReferenceQueue() {
        if (queue != null)
            return queue;
       
        queue = new ReferenceQueue();
        thread = new CleanerThread();
        return queue;
    }
View Full Code Here

    /**
     * Initialise this subclass during construction, cloning or deserialization.
     */
    protected void init() {
        queue = new ReferenceQueue();
    }
View Full Code Here

     */
    private void readObject(ObjectInputStream inp) throws IOException, ClassNotFoundException {
        inp.defaultReadObject();
        table = new Entry[inp.readInt()];
        threshold = (int)(table.length * loadFactor);
        queue = new ReferenceQueue();
        Object key = inp.readObject();
        while (key != null) {
            Object value = inp.readObject();
            put(key, value);
            key = inp.readObject();
View Full Code Here

       (e.getMessage())).initCause (e);
    }
    reqsByProcKey = new HashMap ();
    procKeysByReq = new HashMap ();
    ignoredProcs = new ArrayList ();
    reqRefQueue = new ReferenceQueue ();
    reqRefCleaner = new Thread () {
      public void run () {
          while (true) {
        try {
            Reference ref = reqRefQueue.remove ();
View Full Code Here

      assertEquals("Size == 0 after gc", 0, map.size());
   }

   private void forceSoftRefCollection()
   {
      ReferenceQueue queue = new ReferenceQueue();
      SoftReference reference = new SoftReference(new Object(), queue);

      ArrayList list = new ArrayList();
      try
      {
         Random rnd = new Random();
         for(int i = 0; true; i ++)
         {
            BigInteger bi = new BigInteger(16384, rnd);
            list.add(bi);
            if (i%1000==0)
            {
               Reference ref;
               if ( (ref = queue.poll()) != null)
               {
                  System.out.println("Break as the soft reference has been queued: "+ref);
                  break;
               }
            }
View Full Code Here

        /** A weak reference to the document object.  */
        private DocReference doc;
       
        AbstractChangeHandler(DefaultStyledDocument d) {
            Class c = getClass();
            ReferenceQueue q;
            synchronized (queueMap) {
                q = queueMap.get(c);
                if (q == null) {
                    q = new ReferenceQueue();
                    queueMap.put(c, q);
                }
            }
            doc = new DocReference(d, q);
        }
View Full Code Here

         *
         * A change listener becomes "stale" when its document is cleaned by GC.
         */
        static List<ChangeListener> getStaleListeners(ChangeListener l) {
            List<ChangeListener> staleListeners = new ArrayList<ChangeListener>();
            ReferenceQueue q = queueMap.get(l.getClass());
           
            if (q != null) {
                DocReference r;           
                synchronized (q) {
                    while ((r = (DocReference) q.poll()) != null) {
                        staleListeners.add(r.getListener());
                    }
                }
            }
           
View Full Code Here

                    hardMap = new LRUMap(hardSize, this);
                } else {
                    hardMap = new LRUMap(hardSize, this);
                }
            }
            referenceQueue = new ReferenceQueue();
            logInterval = aLogInterval;
            lastLogTime = System.currentTimeMillis();
            this.hardSize = hardSize;
            this.softSize = softSize;
            hits = 0;
View Full Code Here

  implied[0] = '\n';
  replace(0, 0, implied, implied.length);

  marks = new MarkVector();
  search = new MarkData(0);
  queue = new ReferenceQueue();
    }
View Full Code Here

TOP

Related Classes of java.lang.ref.ReferenceQueue

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.