@InterfaceAudience.Public @InterfaceStability.Evolving public class SafeThread extends Object implements Runnable, TimerTaskReceiver
onTimerTask(EnhancedTimerTask) to add an event to this thread
for execution. FIFOQueue to store and to execute. TimerTaskListener
addTimerTaskListener(TimerTaskListener, Class) to
register for notifications.removeTimerTaskListener(TimerTaskListener, Class) to
unregister from notifications.| Constructor and Description |
|---|
SafeThread(ExecutorService threadPool)
Instantiates a new safe thread.
|
SafeThread(String name,
ExecutorService threadPool)
Instantiates a new safe thread.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addTimerTaskListener(TimerTaskListener listener,
Class<? extends EnhancedTimerTask> type)
Adds the timer task listener.
|
long |
getInterval()
Gets the interval.
|
Map<Class<? extends EnhancedTimerTask>,TimerTaskListener> |
getListeners()
Gets the listeners.
|
boolean |
isRunning()
Checks if it is running.
|
void |
onTimerTask(EnhancedTimerTask timerTask)
Updates the processing Engine with the
EnhancedTimerTask, and it
should be a light weight implementation and synchronized. |
boolean |
removeTimerTaskListener(TimerTaskListener listener,
Class<? extends EnhancedTimerTask> type)
Removes the timer task listener.
|
void |
run() |
void |
setInterval(long interval)
Sets the interval.
|
void |
shutdown()
Shutdowns the backGround
SafeThread. |
void |
start()
Causes this thread to begin execution;.
|
void |
stop()
Forces the thread to stop executing.
|
public SafeThread(ExecutorService threadPool)
threadPool - the thread poolpublic SafeThread(String name, ExecutorService threadPool)
name - the namethreadPool - the thread poolpublic void start()
public void stop()
public boolean isRunning()
public void shutdown()
SafeThread.public Map<Class<? extends EnhancedTimerTask>,TimerTaskListener> getListeners()
public boolean addTimerTaskListener(TimerTaskListener listener, Class<? extends EnhancedTimerTask> type)
listener - the listenertype - the typepublic boolean removeTimerTaskListener(TimerTaskListener listener, Class<? extends EnhancedTimerTask> type)
listener - the listenertype - the typepublic void onTimerTask(EnhancedTimerTask timerTask)
TimerTaskReceiverEnhancedTimerTask, and it
should be a light weight implementation and synchronized.onTimerTask in interface TimerTaskReceivertimerTask - the timer taskpublic void setInterval(long interval)
interval - the interval to setpublic long getInterval()
Copyright © 2016 utils4j. All Rights Reserved.