Synchronize on threads on wait/notify
[kaka/cakelight.git] / src / kaka / cakelight / mode / AmbientMode.java
index ba816d5..9843084 100644 (file)
@@ -33,7 +33,9 @@ public class AmbientMode extends Mode { // TODO split into DynamicAmbient and St
     @Override
     public void resume() {
         isPaused = false;
-        thread.notify();
+       synchronized (thread) {
+           thread.notify();
+       }
     }
 
     @Override
@@ -49,7 +51,9 @@ public class AmbientMode extends Mode { // TODO split into DynamicAmbient and St
                     int index = 0;
                     while (!isInterrupted()) {
                         if (isPaused) {
-                            wait();
+                           synchronized (thread) {
+                               wait();
+                           }
                         }
                         LedFrame frame = LedFrame.from(config);
                         updateFrame(frame, System.currentTimeMillis() - start, index);
@@ -58,7 +62,7 @@ public class AmbientMode extends Mode { // TODO split into DynamicAmbient and St
                         Thread.sleep(20);
                     }
                 } catch (InterruptedException e) {
-                    e.printStackTrace();
+                    // e.printStackTrace();
                 }
             }
         };