From 85e1d48e889020b1159338ff35f47ee364f45285 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 13 Feb 2011 03:45:34 +0000 Subject: [PATCH] Fixes a deadlock issue in CraftScheduler By: Raphfrk --- .../org/bukkit/craftbukkit/scheduler/CraftScheduler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java index d50a036e63..edf5bae8d2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -20,6 +20,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable { private final CraftThreadManager craftThreadManager = new CraftThreadManager(); private final LinkedList mainThreadQueue = new LinkedList(); + private final LinkedList syncedTasks = new LinkedList(); private final TreeMap schedulerQueue = new TreeMap(); @@ -111,11 +112,14 @@ public class CraftScheduler implements BukkitScheduler, Runnable { try { this.currentTick = currentTick; while (!mainThreadQueue.isEmpty()) { - mainThreadQueue.removeFirst().run(); + syncedTasks.addLast(mainThreadQueue.removeFirst()); } } finally { mainThreadLock.unlock(); } + while(!syncedTasks.isEmpty()) { + syncedTasks.removeFirst().run(); + } } }