// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.jcajce.provider.drbg;

import java.util.logging.Level;
import java.util.LinkedList;
import java.util.logging.Logger;

class EntropyDaemon implements Runnable
{
    private static final Logger LOG;
    private final LinkedList<Runnable> tasks;
    
    public EntropyDaemon() {
        this.tasks = new LinkedList<Runnable>();
    }
    
    void addTask(final Runnable e) {
        synchronized (this.tasks) {
            this.tasks.add(e);
        }
    }
    
    @Override
    public void run() {
        while (!Thread.currentThread().isInterrupted()) {
            final Runnable runnable;
            synchronized (this.tasks) {
                runnable = this.tasks.poll();
            }
            if (runnable != null) {
                try {
                    runnable.run();
                }
                catch (final Throwable t) {}
            }
            else {
                try {
                    Thread.sleep(5000L);
                }
                catch (final InterruptedException ex) {
                    Thread.currentThread().interrupt();
                }
            }
        }
        if (EntropyDaemon.LOG.isLoggable(Level.FINE)) {
            EntropyDaemon.LOG.fine("entropy thread interrupted - exiting");
        }
    }
    
    static {
        LOG = Logger.getLogger(EntropyDaemon.class.getName());
    }
}
