PARAMETER
- Parameter typeRESULT
- Result typePROGRESS
- Progress typefinal class ThreadElement<PARAMETER,RESULT,PROGRESS> extends java.lang.Object implements java.lang.Comparable<ThreadElement<PARAMETER,RESULT,PROGRESS>>
ThreadManager
internal use onlyModifier and Type | Field and Description |
---|---|
private boolean |
alive
Indicates if the element is alive
|
private int |
id
Thread element ID
|
private static int |
nextId
Next thread element ID
|
private PARAMETER |
parameter
Parameter to give to the thread
|
private java.util.concurrent.locks.ReentrantLock |
reentrantLock
For synchronize
|
private long |
repeatTime
Repeat time
|
private ThreadedTask<PARAMETER,RESULT,PROGRESS> |
threadedTask
Task to do
|
private long |
timeToAct
Time when do the action
|
Constructor and Description |
---|
ThreadElement(ThreadedTask<PARAMETER,RESULT,PROGRESS> threadedTask,
PARAMETER parameter,
long timeToAct)
Create a new instance of ThreadElement
|
ThreadElement(ThreadedTask<PARAMETER,RESULT,PROGRESS> threadedTask,
PARAMETER parameter,
long timeToAct,
long repeatTime)
Create a new instance of ThreadElement
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ThreadElement<PARAMETER,RESULT,PROGRESS> threadElement)
Compare the element to an other.
|
(package private) void |
destroy()
Destroy properly the element to free some memory
|
(package private) boolean |
doRepeat()
Apply the repeat time, if need
|
(package private) int |
getID()
Thread element ID
|
(package private) long |
getTimeToAct()
Time when do the task
|
(package private) boolean |
isAlive()
Indicates if the element still alive
|
void |
run()
Do the action
|
private static int nextId
private boolean alive
private int id
private PARAMETER parameter
private final java.util.concurrent.locks.ReentrantLock reentrantLock
private long repeatTime
private ThreadedTask<PARAMETER,RESULT,PROGRESS> threadedTask
private long timeToAct
ThreadElement(ThreadedTask<PARAMETER,RESULT,PROGRESS> threadedTask, PARAMETER parameter, long timeToAct)
threadedTask
- Task to doparameter
- Parameter to give to the tasktimeToAct
- Time when do the taskThreadElement(ThreadedTask<PARAMETER,RESULT,PROGRESS> threadedTask, PARAMETER parameter, long timeToAct, long repeatTime)
threadedTask
- Task to doparameter
- Parameter to give to the tasktimeToAct
- Time when do the taskrepeatTime
- Repeat timevoid destroy()
boolean doRepeat()
true
if the task need to be repeat. false
if the task is just do onceint getID()
long getTimeToAct()
boolean isAlive()
true
if the element still alivepublic int compareTo(ThreadElement<PARAMETER,RESULT,PROGRESS> threadElement)
-1 | If is is before the compared task |
---|---|
0 | If It is on same time as compared task |
1 | If it is after the compared task |
compareTo
in interface java.lang.Comparable<ThreadElement<PARAMETER,RESULT,PROGRESS>>
threadElement
- Element to compareComparable.compareTo(java.lang.Object)
public void run()