Class QueuePopulationThread<E>

  • All Implemented Interfaces:
    Runnable
    Direct Known Subclasses:
    KeyPairPopulationThread

    public abstract class QueuePopulationThread<E>
    extends Thread
    A thread for populating a QueueWithSpare. This thread will maintain a queue with a maximum number of elements and will check to see if there need to be new elements at a given interval. Generally this means that every request will receive a new element, but should demand outstrip supply, the last element in the queue will be returned until new elements can be created. This allows for generating expensive items (such as key pairs) without creating a bottleneck in the system.

    Created by Jeff Gaynor
    on 2/20/12 at 11:03 AM

    • Constructor Detail

      • QueuePopulationThread

        protected QueuePopulationThread​(MyLoggingFacade logger)
      • QueuePopulationThread

        protected QueuePopulationThread​(QueueWithSpare<E> q)
      • QueuePopulationThread

        protected QueuePopulationThread​(int maxQueueSize,
                                        long sleepInterval,
                                        QueueWithSpare<E> q)
    • Method Detail

      • isStopThread

        public boolean isStopThread()
      • setStopThread

        public void setStopThread​(boolean stopThread)
      • createNew

        protected abstract E createNew()
      • log

        protected void log​(String x)
      • run

        public void run()
        Specified by:
        run in interface Runnable
        Overrides:
        run in class Thread