Class ThreadPoolImpl

java.lang.Object
com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl
All Implemented Interfaces:
ThreadPool, Closeable, AutoCloseable

public class ThreadPoolImpl extends Object implements ThreadPool
  • Constructor Summary

    Constructors
    Constructor
    Description
    ThreadPoolImpl(int minSize, int maxSize, long timeout, String threadpoolName)
    This constructor is used to create bounded threadpool
    ThreadPoolImpl(String threadpoolName)
    This constructor is used to create an unbounded threadpool in the ThreadGroup of the current thread
    ThreadPoolImpl(ThreadGroup tg, String threadpoolName)
    This constructor is used to create an unbounded threadpool
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    This method returns the average elapsed time taken to complete a Work item.
    void
     
    int
    This method will return the current number of threads in the threadpool.
    long
    This method returns the number of Work items processed by the threadpool
    This method will return any instance of the WorkQueue.
    This method will return the name of the threadpool.
    getWorkQueue(int queueId)
    This method will return an instance of the of the WorkQueue given a queueId.
    long
    This method will return the time in milliseconds when idle threads in the threadpool are removed.
    int
    This method will return the maximum number of threads in the threadpool at any point in time, for the life of the threadpool
    int
    This method will return the minimum number of threads maintained by the threadpool.
    int
    This method will return the number of available threads in the threadpool which are waiting for work.
    int
    This method will return the number of busy threads in the threadpool This method returns a value which is not synchronized.
    int
    This method will return the number of WorkQueues serviced by the threadpool.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ThreadPoolImpl

      public ThreadPoolImpl(ThreadGroup tg, String threadpoolName)
      This constructor is used to create an unbounded threadpool
    • ThreadPoolImpl

      public ThreadPoolImpl(String threadpoolName)
      This constructor is used to create an unbounded threadpool in the ThreadGroup of the current thread
    • ThreadPoolImpl

      public ThreadPoolImpl(int minSize, int maxSize, long timeout, String threadpoolName)
      This constructor is used to create bounded threadpool
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getAnyWorkQueue

      public WorkQueue getAnyWorkQueue()
      Description copied from interface: ThreadPool
      This method will return any instance of the WorkQueue. If the ThreadPool instance only services one WorkQueue then that WorkQueue instance will be returned. If there are more than one WorkQueues serviced by this ThreadPool, then this method would return a WorkQueue based on the implementation of the class that implements this interface. For PE 8.0 we would return a WorkQueue in a roundrobin fashion everytime this method is called. In the future we could allow pluggability of Policy objects for this.
      Specified by:
      getAnyWorkQueue in interface ThreadPool
    • getWorkQueue

      public WorkQueue getWorkQueue(int queueId) throws NoSuchWorkQueueException
      Description copied from interface: ThreadPool
      This method will return an instance of the of the WorkQueue given a queueId. This will be useful in situations where there are more than one WorkQueues managed by the ThreadPool and the user of the ThreadPool wants to always use the same WorkQueue for doing the Work. If the number of WorkQueues in the ThreadPool are 10, then queueIds will go from 0-9
      Specified by:
      getWorkQueue in interface ThreadPool
      Throws:
      NoSuchWorkQueueException - thrown when queueId passed is invalid
    • minimumNumberOfThreads

      public int minimumNumberOfThreads()
      Description copied from interface: ThreadPool
      This method will return the minimum number of threads maintained by the threadpool.
      Specified by:
      minimumNumberOfThreads in interface ThreadPool
    • maximumNumberOfThreads

      public int maximumNumberOfThreads()
      Description copied from interface: ThreadPool
      This method will return the maximum number of threads in the threadpool at any point in time, for the life of the threadpool
      Specified by:
      maximumNumberOfThreads in interface ThreadPool
    • idleTimeoutForThreads

      public long idleTimeoutForThreads()
      Description copied from interface: ThreadPool
      This method will return the time in milliseconds when idle threads in the threadpool are removed.
      Specified by:
      idleTimeoutForThreads in interface ThreadPool
    • currentNumberOfThreads

      public int currentNumberOfThreads()
      Description copied from interface: ThreadPool
      This method will return the current number of threads in the threadpool. This method returns a value which is not synchronized.
      Specified by:
      currentNumberOfThreads in interface ThreadPool
    • numberOfAvailableThreads

      public int numberOfAvailableThreads()
      Description copied from interface: ThreadPool
      This method will return the number of available threads in the threadpool which are waiting for work. This method returns a value which is not synchronized.
      Specified by:
      numberOfAvailableThreads in interface ThreadPool
    • numberOfBusyThreads

      public int numberOfBusyThreads()
      Description copied from interface: ThreadPool
      This method will return the number of busy threads in the threadpool This method returns a value which is not synchronized.
      Specified by:
      numberOfBusyThreads in interface ThreadPool
    • averageWorkCompletionTime

      public long averageWorkCompletionTime()
      Description copied from interface: ThreadPool
      This method returns the average elapsed time taken to complete a Work item.
      Specified by:
      averageWorkCompletionTime in interface ThreadPool
    • currentProcessedCount

      public long currentProcessedCount()
      Description copied from interface: ThreadPool
      This method returns the number of Work items processed by the threadpool
      Specified by:
      currentProcessedCount in interface ThreadPool
    • getName

      public String getName()
      Description copied from interface: ThreadPool
      This method will return the name of the threadpool.
      Specified by:
      getName in interface ThreadPool
    • numberOfWorkQueues

      public int numberOfWorkQueues()
      This method will return the number of WorkQueues serviced by the threadpool.
      Specified by:
      numberOfWorkQueues in interface ThreadPool