1
0
mirror of https://github.com/fazo96/AIrium.git synced 2025-01-10 09:34:20 +01:00

minor performance improvements

This commit is contained in:
Enrico Fasoli 2015-08-08 12:26:24 +02:00
parent 3ead974ee2
commit f6ae99b23a

View File

@ -164,14 +164,16 @@ public class World implements Runnable {
while (plants.size() < nPlants) { while (plants.size() < nPlants) {
spawnVegetable(); spawnVegetable();
} }
if (multithreading) { // Multi-thread: use workers if (multithreading) {
for (Vegetable v : plants) { // Multi-thread: use workers
v.update();
}
for (Creature c : creatures) { for (Creature c : creatures) {
c.startWorker(); c.startWorker();
} }
Thread.yield(); }
for (Vegetable v : plants) {
v.update();
}
if (multithreading) {
int finishedCount = 0; int finishedCount = 0;
while (finishedCount < creatures.size()) { while (finishedCount < creatures.size()) {
finishedCount = 0; finishedCount = 0;