diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index 9fea4fb3ca..bdddf0b5fa 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -32,7 +32,7 @@ import org.bukkit.scheduler.BukkitWorker;
*
Changing the period on a task is delicate.
* Any future task needs to notify waiting threads.
* Async tasks must be synchronized to make sure that any thread that's finishing will remove itself from {@link #runners}.
- * Another utility method is provided for this, {@link #cancelTask(CraftTask)}
+ * Another utility method is provided for this, {@link #cancelTask(int)}
* {@link #runners} provides a moderately up-to-date view of active tasks.
* If the linked head to tail set is read, all remaining tasks that were active at the time execution started will be located in runners.
* Async tasks are responsible for removing themselves from runners
@@ -60,7 +60,10 @@ public class CraftScheduler implements BukkitScheduler {
private final PriorityQueue pending = new PriorityQueue(10,
new Comparator() {
public int compare(final CraftTask o1, final CraftTask o2) {
- return (int) (o1.getNextRun() - o2.getNextRun());
+ int value = (int) (o1.getNextRun() - o2.getNextRun());
+
+ // If the tasks should run on the same tick they should be run FIFO
+ return value != 0 ? value : o1.getTaskId() - o2.getTaskId();
}
});
/**