public abstract class Daemon
extends java.lang.Object
implements java.lang.Runnable
| Constructor and Description |
|---|
Daemon() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
interrupt(boolean waitingHeuristic)
Politely asks the daemon to reconsider its termination condition.
|
boolean |
isRunning()
Returns whether the daemon is in the process of terminating
|
boolean |
isThreadRunning()
Determines if this daemon's thread is alive
|
protected boolean |
shouldStartAsDaemon()
Overloading this method to return true will start this daemon's thread as a Daemon Thread
|
java.lang.Thread |
startThread()
Starts this daemon, creating a new thread for it (the name of which will be set to the SimpleName of its class)
|
java.lang.Thread |
startThread(java.lang.String name)
Starts this daemon, creating a new thread for it
|
static void |
stopAll(java.util.List<? extends Daemon> daemons)
Stop all the daemons in a given list:
|
void |
stopThread()
Requests the daemon terminate by setting a flag and sending an interrupt to the thread
|
static boolean |
waitForTermination(Daemon daemon,
long timeoutMillis) |
static boolean |
waitForTermination(java.util.List<? extends Daemon> daemons,
long timeoutMillis) |
public java.lang.Thread startThread()
throws java.lang.IllegalThreadStateException
java.lang.IllegalThreadStateException - If the daemon is still runningpublic java.lang.Thread startThread(java.lang.String name)
throws java.lang.IllegalThreadStateException
name - String The name for the threadjava.lang.IllegalThreadStateException - If the daemon is still runningpublic boolean isRunning()
public void stopThread()
protected void interrupt(boolean waitingHeuristic)
waitingHeuristic - boolean True if the Daemon thinks this thread's blockedpublic boolean isThreadRunning()
protected boolean shouldStartAsDaemon()
public static void stopAll(java.util.List<? extends Daemon> daemons)
daemons - List[Daemon] The daemons to stoppublic static boolean waitForTermination(Daemon daemon, long timeoutMillis)
public static boolean waitForTermination(java.util.List<? extends Daemon> daemons, long timeoutMillis)
Copyright © 2014. All Rights Reserved.