From f6ae99b23a7114f10433905ef5a7d0b761f66df4 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Sat, 8 Aug 2015 12:26:24 +0200 Subject: [PATCH] minor performance improvements --- core/src/logic/World.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/src/logic/World.java b/core/src/logic/World.java index e83e709..90e32a4 100644 --- a/core/src/logic/World.java +++ b/core/src/logic/World.java @@ -164,14 +164,16 @@ public class World implements Runnable { while (plants.size() < nPlants) { spawnVegetable(); } - if (multithreading) { // Multi-thread: use workers - for (Vegetable v : plants) { - v.update(); - } + if (multithreading) { + // Multi-thread: use workers for (Creature c : creatures) { c.startWorker(); } - Thread.yield(); + } + for (Vegetable v : plants) { + v.update(); + } + if (multithreading) { int finishedCount = 0; while (finishedCount < creatures.size()) { finishedCount = 0;