Class ThreadPool

java.lang.Object
java.lang.ThreadGroup
org.jpos.util.ThreadPool
All Implemented Interfaces:
Thread.UncaughtExceptionHandler, Configurable, Loggeable, LogSource, ThreadPoolMBean

Deprecated.
Used Executor framework
Implements a ThreadPool with the ability to run simple Runnable tasks as well as Jobs (supervised Runnable tasks)
Since:
1.1
  • Field Details

  • Constructor Details

    • ThreadPool

      public ThreadPool(int poolSize, int maxPoolSize)
      Deprecated.
      Constructs a ThreadPool with the default name "ThreadPool".
      Parameters:
      poolSize - starting pool size
      maxPoolSize - maximum number of threads on this pool
    • ThreadPool

      public ThreadPool(int poolSize, int maxPoolSize, String name)
      Deprecated.
      Constructs a ThreadPool with an explicit name.
      Parameters:
      poolSize - starting pool size
      maxPoolSize - maximum number of threads on this pool
      name - pool name
    • ThreadPool

      public ThreadPool()
      Deprecated.
      Default constructor for ThreadPool
  • Method Details

    • close

      public void close()
      Deprecated.
      Closes the pool queue and stops accepting new jobs.
    • execute

      public void execute(Runnable action) throws BlockingQueue.Closed
      Deprecated.
      Executes a runnable using the pool infrastructure.
      Parameters:
      action - runnable to execute
      Throws:
      BlockingQueue.Closed - if the pool is no longer accepting jobs
    • dump

      public void dump(PrintStream p, String indent)
      Deprecated.
      Description copied from interface: Loggeable
      Dumps a human-readable representation of this object to the print stream.
      Specified by:
      dump in interface Loggeable
      Parameters:
      p - the output stream
      indent - indentation prefix
    • getJobCount

      public int getJobCount()
      Deprecated.
      Description copied from interface: ThreadPoolMBean
      Returns the number of jobs processed by this pool.
      Specified by:
      getJobCount in interface ThreadPoolMBean
      Returns:
      number of jobs processed by this pool
    • getPoolSize

      public int getPoolSize()
      Deprecated.
      Description copied from interface: ThreadPoolMBean
      Returns the number of running threads in the pool.
      Specified by:
      getPoolSize in interface ThreadPoolMBean
      Returns:
      number of running threads
    • getMaxPoolSize

      public int getMaxPoolSize()
      Deprecated.
      Description copied from interface: ThreadPoolMBean
      Returns the maximum number of threads allowed in the pool.
      Specified by:
      getMaxPoolSize in interface ThreadPoolMBean
      Returns:
      max number of active threads allowed
    • getActiveCount

      public int getActiveCount()
      Deprecated.
      Returns the number of threads currently executing a job.
      Returns:
      number of active threads
    • getIdleCount

      public int getIdleCount()
      Deprecated.
      Returns the number of threads currently waiting for work.
      Specified by:
      getIdleCount in interface ThreadPoolMBean
      Returns:
      number of idle threads
    • getAvailableCount

      public int getAvailableCount()
      Deprecated.
      Returns the number of threads available to accept new work without spawning.
      Returns:
      number of available threads
    • getPendingCount

      public int getPendingCount()
      Deprecated.
      Description copied from interface: ThreadPoolMBean
      Returns the number of pending jobs.
      Specified by:
      getPendingCount in interface ThreadPoolMBean
      Returns:
      number of Pending jobs
    • supervise

      public void supervise()
      Deprecated.
      Supervises pooled threads and interrupts expired supervised jobs.
    • setLogger

      public void setLogger(Logger logger, String realm)
      Deprecated.
      Description copied from interface: LogSource
      Attaches a Logger and realm to this log source.
      Specified by:
      setLogger in interface LogSource
      Parameters:
      logger - the logger to use
      realm - the log realm (diagnostic label)
    • getRealm

      public String getRealm()
      Deprecated.
      Description copied from interface: LogSource
      Returns the log realm associated with this source.
      Specified by:
      getRealm in interface LogSource
      Returns:
      log realm
    • getLogger

      public Logger getLogger()
      Deprecated.
      Description copied from interface: LogSource
      Returns the Logger associated with this source.
      Specified by:
      getLogger in interface LogSource
      Returns:
      the Logger
    • setConfiguration

      Deprecated.
      Description copied from interface: Configurable
      Configures this object with the supplied Configuration.
      Specified by:
      setConfiguration in interface Configurable
      Parameters:
      cfg - Configuration object
      Throws:
      ConfigurationException - if configuration is invalid
    • getThreadPool

      Deprecated.
      Retrieves a thread pool from NameRegistrar given its name, unique identifier.
      Parameters:
      name - Name of the thread pool to retrieve, must be the same as the name property of the thread-pool tag in the QSP config file
      Returns:
      returns the retrieved instance of thread pool
      Throws:
      NameRegistrar.NotFoundException - thrown when there is not a thread-pool registered under this name.