|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--jason.service.pool.ThreadCapsule
This class represents a layer or a capsule over the client processing thread and is responsible for
managing the life-cycle of individual threads. Any interaction with the thread shall have to pass
through the capsule.
Author - Sanjay"Ironluca"Debnath Ironluca@yahoo.com
Last Modified - 9/03/2001
Field Summary | |
protected ActivePoolInt |
activePool
Reference of the ActivePool for the capsule. |
protected java.lang.Runnable |
coreThread
The thread which is embedded in this capsule and is responsible to process a client. |
protected boolean |
keepAlive
This variable is used to control the thread embedded in the threadCapsule & to keep it alive or terminate it. |
protected PassivePoolInt |
passivePool
|
protected boolean |
state
The state of the capsule, active or passive - false indicates the thread is not servicing any client right now. |
protected java.lang.Class |
threadClass
The class of the coreThread that is embeded in this threadCapsule. |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
ThreadCapsule(java.lang.Class threadClass)
The only visible constructor for the class. |
Method Summary | |
void |
activateThreadCapsule()
This method must be called by the client to activate the thread capsule as well as the embedded thread. |
ActivePoolInt |
getActivePool()
This method returns the reference to the activePool of which th ThreadCapsule is a member. |
java.lang.Runnable |
getCoreThread()
This method returns the coreThread stored in this ThreadCapsule. |
boolean |
getKeepAlive()
Returns the value of the keepAlive variable of the ThreadCapsule. |
PassivePoolInt |
getPassivePool()
This method returns the reference to the passivePool of which th ThreadCapsule is a member. |
boolean |
getState()
This method merely returns the state of the ThreadCapsule. |
java.lang.Class |
getThreadClass()
Returns the threadClass reference of the ThreadCapsule. |
void |
run()
This overridden method is responsible to run the algorithm required to service the client. |
void |
setActivePool(ActivePoolInt activePool)
This method sets the activePool reference of the ThreadCapsule. |
void |
setCoreThread(java.lang.Runnable coreThread)
This method is provided for optimization purpose only and should only be called by the ThreadPool
only. |
void |
setKeepAlive(boolean keepAlive)
This method sets the keepAlive variable of the ThreadCapsule, which is responsible
to control the life-cycle of the ThreadCapsule. |
void |
setPassivePool(PassivePoolInt passivePool)
This method sets the passivePool reference of the ThreadCapsule. |
void |
setState(boolean state)
This method sets the state variable of the ThreadCapsule. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.Class threadClass
coreThread
that is embeded in this threadCapsule.
protected java.lang.Runnable coreThread
protected boolean state
protected boolean keepAlive
protected ActivePoolInt activePool
ActivePool
for the capsule.
protected PassivePoolInt passivePool
Constructor Detail |
public ThreadCapsule(java.lang.Class threadClass) throws java.lang.InstantiationException, java.lang.IllegalAccessException
ThreadPool
to create individual ThreadCapsules in the pool.
java.lang.InstantiationException
- If there is no visible default constructor for the threadClass
.
java.lang.IllegalAccessException
- If there is no public constructor for the threadClass
.Method Detail |
public void run()
coreThread
.activePool
and pushes back to the passivePool
.
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void setActivePool(ActivePoolInt activePool)
activePool
reference of the ThreadCapsule.
setActivePool
in interface ThreadCapsuleInt
ActivePool
,
ActivePoolInt
public ActivePoolInt getActivePool()
activePool
of which th ThreadCapsule is a member.
getActivePool
in interface ThreadCapsuleInt
ActivePool
.ActivePool
,
ActivePoolInt
public void setPassivePool(PassivePoolInt passivePool)
passivePool
reference of the ThreadCapsule.
setPassivePool
in interface ThreadCapsuleInt
PassivePool
,
PassivePoolInt
public PassivePoolInt getPassivePool()
passivePool
of which th ThreadCapsule is a member.
getPassivePool
in interface ThreadCapsuleInt
PassivePool
.PassivePool
,
PassivePoolInt
public void setState(boolean state)
state
variable of the ThreadCapsule.ThreadPool
or the controller of the
thread pool.
setState
in interface ThreadCapsuleInt
public boolean getState()
state
of the ThreadCapsule.
getState
in interface ThreadCapsuleInt
state
of the ThreadCapsule.public void setKeepAlive(boolean keepAlive)
keepAlive
variable of the ThreadCapsule, which is responsible
to control the life-cycle of the ThreadCapsule.ThreadPool
or the controller of the
thread pool.
setKeepAlive
in interface ThreadCapsuleInt
public boolean getKeepAlive()
keepAlive
variable of the ThreadCapsule.
getKeepAlive
in interface ThreadCapsuleInt
public java.lang.Class getThreadClass()
threadClass
reference of the ThreadCapsule.
getThreadClass
in interface ThreadCapsuleInt
public java.lang.Runnable getCoreThread()
coreThread
stored in this ThreadCapsule. The coreThread
is responsible to service the client.
getCoreThread
in interface ThreadCapsuleInt
public void setCoreThread(java.lang.Runnable coreThread)
ThreadPool
only.
coreThread
- - The thread to be embedded in the ThreadCapsule.public void activateThreadCapsule()
activateThreadCapsule
in interface ThreadCapsuleInt
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |