bugfixed race condition

This commit is contained in:
Fredrik Osterlind 2012-05-02 16:04:16 +02:00
parent 34e7de389c
commit 99b17092e4
1 changed files with 5 additions and 3 deletions

View File

@ -116,15 +116,17 @@ public class LogScriptEngine {
/* Only called from the simulation loop */ /* Only called from the simulation loop */
private void stepScript() { private void stepScript() {
/* Release script - halt simulation */ /* Release script - halt simulation */
if (semaphoreScript == null || semaphoreSim == null) { Semaphore semScript = semaphoreScript;
Semaphore semSim = semaphoreSim;
if (semScript == null || semSim == null) {
return; return;
} }
semaphoreScript.release(); semScript.release();
/* ... script executing ... */ /* ... script executing ... */
try { try {
semaphoreSim.acquire(); semSim.acquire();
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }