|
Joram 5.0.7 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.joram.kclient.Daemon
public abstract class Daemon
The Daemon class represents a basic active component in a server. It provides usefull code to start and safely stop inner Thread.
Main loop of daemon:
try { while (running) { canStop = true; // Get a notification, then execute the right reaction. try { // Get a request ... } catch (InterruptedException exc) { continue; } canStop = false; // executes the request ... } } finally { finish(); }
Field Summary | |
---|---|
protected boolean |
canStop
Boolean variable used to stop the daemon properly. |
protected int |
priority
The priority that is assigned to the daemon. |
protected boolean |
running
Boolean variable used to stop the daemon properly. |
protected java.lang.Thread |
thread
The active component of this daemon. |
Constructor Summary | |
---|---|
protected |
Daemon(java.lang.String name)
Allocates a new Daemon object. |
Method Summary | |
---|---|
protected abstract void |
close()
Releases any resources attached to this daemon. |
protected void |
finish()
|
java.lang.String |
getName()
Returns this daemon 's name. |
void |
interrupt()
Interrupts this daemon. |
boolean |
isCurrentThread()
Tests if the daemon's thread is the current one. |
boolean |
isRunning()
Tests if this daemon is alive. |
void |
setPriority(int newPriority)
Changes the priority of this daemon. |
protected abstract void |
shutdown()
Interupts a thread that waits for long periods. |
void |
start()
Causes this daemon to begin execution. |
void |
stop()
Forces the daemon to stop executing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.lang.Runnable |
---|
run |
Field Detail |
---|
protected volatile boolean running
start
,
stop
protected volatile boolean canStop
running
variable between
each reaction)
protected java.lang.Thread thread
protected int priority
priority
that is assigned to the daemon.
Constructor Detail |
---|
protected Daemon(java.lang.String name)
name
- the name of the new DaemonMethod Detail |
---|
public boolean isRunning()
public final java.lang.String getName()
daemon
's name.
daemon
's name.public void setPriority(int newPriority)
Thread.setPriority
public void start()
java.lang.IllegalThreadStateException
- If the daemon was already started.protected abstract void close()
protected abstract void shutdown()
public void interrupt()
protected final void finish()
public void stop()
public boolean isCurrentThread()
|
Joram 5.0.7 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |