|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfr.dyade.aaa.util.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 java.lang.ThreadGroup |
group
The group of this thread |
protected org.objectweb.util.monolog.api.Logger |
logmon
|
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. |
protected |
Daemon(java.lang.String name,
org.objectweb.util.monolog.api.Logger logmon)
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 |
setDaemon(boolean daemon)
Marks the daemon's thread as either a daemon thread a user thread. |
void |
setPriority(int newPriority)
Changes the priority of this daemon. |
void |
setThreadGroup(java.lang.ThreadGroup group)
Set the thread group to which this daemon's thread belongs. |
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. |
java.lang.String |
toString()
Returns a string representation of this daemon. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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.
protected java.lang.ThreadGroup group
protected org.objectweb.util.monolog.api.Logger logmon
Constructor Detail |
protected Daemon(java.lang.String name)
name
- the name of the new Daemonprotected Daemon(java.lang.String name, org.objectweb.util.monolog.api.Logger logmon)
name
- the name of the new Daemonlogmon
- inherited logging monitorMethod Detail |
public boolean isRunning()
public final java.lang.String getName()
daemon
's name.
daemon
's name.public java.lang.String toString()
public void setDaemon(boolean daemon)
java.lang.IllegalThreadStateException
- if this daemon was already active.public void setPriority(int newPriority)
Thread.setPriority
public void setThreadGroup(java.lang.ThreadGroup group)
java.lang.IllegalThreadStateException
- if this daemon was already active.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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |