Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 
 package org.jruby.util;
 
A general purpose reference tracker & reaper utility class.
 
public final class ReferenceReaper {
    public final ReferenceQueue referenceQueue = new ReferenceQueue();
    private final Thread reaperThread;
    
    private ReferenceReaper() {
         = new Thread("ReferenceReaper");
        .setDaemon(true);
        .start();
    }
    private static final class SingletonHolder {
        private static final ReferenceReaper INSTANCE = new ReferenceReaper();
    }
    public static final ReferenceReaper getInstance() {
        return .;
    }
    private final Runnable reaper = new Runnable() {
        public void run() {
            for ( ; ; ) {
                try {
                    Reference r = .remove();
                    try {
                        if (r instanceof Runnable) {
                            ((Runnabler).run();
                        }
                    } finally {
                        r.clear();
                    }
                } catch (InterruptedException ex) {
                    break;
                } catch (Throwable t) {
                    continue;
                }
            }
        }
    };
New to GrepCode? Check out our FAQ X