Package org.jini.rio.resources.resource
Class ThreadPool
java.lang.Object
org.jini.rio.resources.resource.ResourcePool
org.jini.rio.resources.resource.ThreadPool
A resource pool to handle a pool of threads
-
Field Summary
FieldsFields inherited from class org.jini.rio.resources.resource.ResourcePool
alloced, freed, identifier, max, min, numCreated -
Constructor Summary
ConstructorsConstructorDescriptionThreadPool(String identifier, int min, int max) Create new named ThreadPool with a specified amount of minimum and maximum elements in the pool -
Method Summary
Modifier and TypeMethodDescriptionprotected Objectcreate()method for creating a specific resource in the sub-classvoiddestroy()destroy all the threads spawned by this poolprotected voidDispose of a resourceget the thread group for this poolstatic voidUnit Testprotected static intnextId()protected booleanValidate a resourceMethods inherited from class org.jini.rio.resources.resource.ResourcePool
allocResource, createResource, createResources, createResources, disposeResource, freeResource, get, get, getAllocedOfType, getAllocedSize, getFreedSize, getIdentifier, getInstance, getMax, getMin, getSize, register, register, register, release, remove, setIdentifier, setMax, setMin, toString
-
Field Details
-
group
-
-
Constructor Details
-
ThreadPool
Create new named ThreadPool with a specified amount of minimum and maximum elements in the pool- Parameters:
identifier- the unique identifier for this instancemin- the minimum number of resources to create at startupmax- the maximum number of resources allowed
-
-
Method Details
-
nextId
protected static int nextId() -
create
method for creating a specific resource in the sub-class- Specified by:
createin classResourcePool- Returns:
- the resource
- Throws:
ResourceUnavailableException- if an error occured in creating the resource
-
dispose
Dispose of a resource- Specified by:
disposein classResourcePool- Parameters:
obj- the resource to dispose
-
validate
Validate a resource- Specified by:
validatein classResourcePool- Parameters:
obj- the resource to validate- Returns:
- true if resource is still valid
-
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
Unit Test
-