MESSAGE - Message typepublic abstract class MessageHandler<MESSAGE>
extends java.lang.Object
messageArrived(Object) is called
 for one of them, then AFTER the code execution its done, its called again.messageArrived(Object) will never called in "same time". It also means, it waits that a message is
 completely manage (exit from messageArrived(Object)) before doing an other stuffterminate() when you need no more the handler| Modifier and Type | Class and Description | 
|---|---|
| private static class  | MessageHandler.Message<ELEMENT>A message | 
| Modifier and Type | Field and Description | 
|---|---|
| private boolean | aliveIndicates if handler still alive | 
| private static int | DEFAULT_WAITDefault waiting time | 
| private java.lang.Thread | internalThreadInternal thread | 
| private java.util.concurrent.atomic.AtomicBoolean | isLockedIndicates if lock is on or off | 
| private java.lang.Object | LOCKObject for synchronization | 
| private Mutex | mutexMutex for exclusive access | 
| private java.util.PriorityQueue<MessageHandler.Message<MESSAGE>> | priorityQueueQueue of messages to give | 
| Constructor and Description | 
|---|
| MessageHandler()Create a new instance of MessageHandler | 
| Modifier and Type | Method and Description | 
|---|---|
| void | cancelMessage(MESSAGE message)Cancel a message. | 
| (package private) void | doTheJob()Manage the messages to delivered | 
| protected void | finalize()Try to free memory if user forget to call  terminate()and the object is garbage collectedParent documentation: | 
| boolean | isAlive()Indicates if the handler still alive and can be used | 
| protected abstract void | messageArrived(MESSAGE message)Called when a message arrived. | 
| void | postDelayedMessage(MESSAGE message,
                  int millisecond)Post a message delayed in a given time | 
| void | postMessage(MESSAGE message)Post a message and deliver it as soon as possible | 
| void | terminate()Stop the handler and destroy it. | 
private static final int DEFAULT_WAIT
private boolean alive
private java.lang.Thread internalThread
private final java.util.concurrent.atomic.AtomicBoolean isLocked
private final java.lang.Object LOCK
private final Mutex mutex
private final java.util.PriorityQueue<MessageHandler.Message<MESSAGE>> priorityQueue
final void doTheJob()
protected void finalize()
                 throws java.lang.Throwable
terminate() and the object is garbage collected finalize in class java.lang.Objectjava.lang.Throwable - On issueObject.finalize()protected abstract void messageArrived(MESSAGE message)
message - Message arrivedpublic final void cancelMessage(MESSAGE message)
postDelayedMessage(Object, int) to cancel it before it is called.message - Message to cancelpublic final boolean isAlive()
true if the handler still alive and can be usedpublic final void postDelayedMessage(MESSAGE message, int millisecond)
message - Message to deliveredmillisecond - Time in millisecond to wait before sending the messagepublic final void postMessage(MESSAGE message)
message - Message to postpublic final void terminate()