public class PriorityRunnable extends Object implements Runnable, PriorityTask
Runnables
that adheres to a priority by implementing PriorityTask
. Uses a
combination of priority
and index
to compare between this
and other priority task instances.
A calculator (e.g. CommandPriorityCalculator
) defines the
priority of the task. This task uses the index
to differentiate between tasks with the same priority,
ensuring the insert order is leading in those scenarios.CommandPriorityCalculator
,
QueryPriorityCalculator
Constructor and Description |
---|
PriorityRunnable(Runnable task,
long priority,
long sequence)
Construct a priority task.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
int |
hashCode() |
long |
priority()
Returns the priority of this task.
|
void |
run() |
long |
sequence()
Returns the sequence of this task.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compareTo
public PriorityRunnable(Runnable task, long priority, long sequence)
task
- The Runnable
that should be executed with a priority
.priority
- The priority of the task
to execute, dedicating the order among tasks.sequence
- The sequence of the task
to execute, dedicating the order among equal priority
tasks.public long priority()
PriorityTask
priority
in interface PriorityTask
public long sequence()
PriorityTask
sequence
in interface PriorityTask
Copyright © 2010–2024. All rights reserved.