|
Class ManagedThread
|
In order to extend the ManagedThread implementers must provide thedoRun() and doShutdown() implementations.
In a regular java.lang.Thread implementers must provide an
implementation of the run() method in which they may provide
an execution loop. This is NOT the case for ManagedThread implementations.
ManagedThread provides the basic loop for the implementer. The harness for
managing state changes and for suspending and resuming the execution is
provided by ManagedThread.
The abstractrun() method must be overriden to provide a
single interation of the loop.
e.g.
Regular java.lang.Thread implemenation
Thread {
void run() {
int state;
while(state!=idle) {
switch(state) {
case(running):
// print "I'm running"
break;
case(graceful_shutdown):
// print "I'm shuting down"
break;
case ...
}
}
}
}
ManagedThread implementation
ManagedThread {
void run() {
// print "I'm running"
}
boolean gracefulShutdown() {
// print "I'm shuting down"
// indicates that the thread has completed graceful shutdown
return true;
}
}
In order to extend the ManagedThread implementers must provide thedoRun() and doShutdown() implementations.
In a regular java.lang.Thread implementers must provide an
implementation of the run() method in which they may provide
an execution loop. This is NOT the case for ManagedThread implementations.
ManagedThread provides the basic loop for the implementer. The harness for
managing state changes and for suspending and resuming the execution is
provided by ManagedThread.
The abstractrun() method must be overriden to provide a
single interation of the loop.
e.g.
Regular java.lang.Thread implemenation
Thread {
void run() {
int state;
while(state!=idle) {
switch(state) {
case(running):
// print "I'm running"
break;
case(graceful_shutdown):
// print "I'm shuting down"
break;
case ...
}
}
}
}
ManagedThread implementation
ManagedThread {
void run() {
// print "I'm running"
}
boolean gracefulShutdown() {
// print "I'm shuting down"
// indicates that the thread has completed graceful shutdown
return true;
}
}
| Field Summary | |
|---|---|
protected final static String |
|
protected ManagedThread.ManagedInnerThread |
|
private Semaphore |
|
protected static Logger |
|
protected ManagedThread |
|
| Constructor Summary | |
|---|---|
public void |
ManagedInnerThread(ManagedThread managedThread) |
public void |
|
| Method Summary | |
|---|---|
protected void |
doResume() |
protected void |
|
protected void |
doStart() |
protected void |
doStop() |
protected void |
|
protected void |
execute() |
protected abstract boolean |
|
public void |
run() |
protected abstract void |
run() |
run() orgracefulShutdown().run() don't need to implement the