public class ThreadPool
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
static int |
POOL_CHECKOUT |
static int |
POOL_CLOSED |
static int |
POOL_INVALID |
static int |
POOL_OK |
Constructor and Description |
---|
ThreadPool(java.lang.String name,
int minSize,
int capacity,
java.lang.Object obj,
java.lang.String methodName,
java.lang.Class[] pTypes) |
Modifier and Type | Method and Description |
---|---|
int |
assign(java.lang.Object[] task,
int id)
It assigns a task to the newly activated id-th thread.
|
int |
checkin(java.lang.Thread thr)
It checks in an unused thread and returns the status code for it.
|
protected int |
checkin(java.lang.Thread thr,
int s)
It checks in a thread and returns it to the pool based on its status.
|
java.lang.Thread |
checkout(long milliSec)
It checks out an idle thread of the object and activates it.
|
void |
close() |
protected java.lang.Thread |
create() |
protected void |
finalize() |
int |
getCapacity()
returns capacity of the pool
|
int |
getCount()
returns number of outstanding tasks
|
int |
getDepth()
returns number of active instances not in use
|
int |
getId(java.lang.Thread thr)
return the ID of the object or -1 if it does not contain such object
|
java.lang.String |
getName() |
int |
getSize()
returns number of active instances regardless it is used or not
|
int |
getStatus() |
int |
getStatus(int id) |
void |
run() |
public static final int POOL_OK
public static final int POOL_CHECKOUT
public static final int POOL_INVALID
public static final int POOL_CLOSED
public ThreadPool(java.lang.String name, int minSize, int capacity, java.lang.Object obj, java.lang.String methodName, java.lang.Class[] pTypes)
public java.lang.Thread checkout(long milliSec)
public int checkin(java.lang.Thread thr)
protected int checkin(java.lang.Thread thr, int s)
public int assign(java.lang.Object[] task, int id)
public void run()
run
in interface java.lang.Runnable
public java.lang.String getName()
public int getCapacity()
public int getSize()
public int getDepth()
public int getCount()
public int getStatus(int id)
public int getStatus()
public int getId(java.lang.Thread thr)
public void close()
protected void finalize()
finalize
in class java.lang.Object
protected java.lang.Thread create() throws java.lang.RuntimeException
java.lang.RuntimeException