Class ThreadPool

java.lang.Object
org.jini.rio.resources.resource.ResourcePool
org.jini.rio.resources.resource.ThreadPool

public class ThreadPool extends ResourcePool
A resource pool to handle a pool of threads
  • Field Details

  • Constructor Details

    • ThreadPool

      public ThreadPool(String identifier, int min, int max)
      Create new named ThreadPool with a specified amount of minimum and maximum elements in the pool
      Parameters:
      identifier - the unique identifier for this instance
      min - the minimum number of resources to create at startup
      max - the maximum number of resources allowed
  • Method Details

    • nextId

      protected static int nextId()
    • create

      protected Object create() throws ResourceUnavailableException
      method for creating a specific resource in the sub-class
      Specified by:
      create in class ResourcePool
      Returns:
      the resource
      Throws:
      ResourceUnavailableException - if an error occured in creating the resource
    • dispose

      protected void dispose(Object obj)
      Dispose of a resource
      Specified by:
      dispose in class ResourcePool
      Parameters:
      obj - the resource to dispose
    • validate

      protected boolean validate(Object obj)
      Validate a resource
      Specified by:
      validate in class ResourcePool
      Parameters:
      obj - the resource to validate
      Returns:
      true if resource is still valid
    • getThreadGroup

      public ThreadGroup getThreadGroup()
      get the thread group for this pool
      Returns:
      the thread group for this pool
    • destroy

      public void destroy()
      destroy all the threads spawned by this pool
    • main

      public static void main(String[] args)
      Unit Test