- this.receiving = true;
- //Log.d("SubscriberElement", "new data: " + (int) ((Box) msg).strength + "(was "+ this.box.strength +"); " + ((Box) msg).rectangle.top_left_x + ", " + ((Box) msg).rectangle.top_left_y + ", " +((Box) msg).rectangle.bottom_right_x + ", " + ((Box) msg).rectangle.bottom_right_y);
-
- this.shape.getBounds().left = this.box.rectangle.top_left_x;
- this.shape.getBounds().top = this.box.rectangle.top_left_y;
- this.shape.getBounds().right = this.box.rectangle.bottom_right_x;
- this.shape.getBounds().bottom = this.box.rectangle.bottom_right_y;
-
- this.setShape();
+
+ lock.lock();
+ try {
+ this.receiving = true;
+ //Log.d("SubscriberElement", "new data: " + (int) ((Box) msg).strength + "(was "+ this.box.strength +"); " + ((Box) msg).rectangle.top_left_x + ", " + ((Box) msg).rectangle.top_left_y + ", " +((Box) msg).rectangle.bottom_right_x + ", " + ((Box) msg).rectangle.bottom_right_y);
+
+ this.shape.setBounds(this.box.rectangle.top_left_x,
+ this.box.rectangle.top_left_y,
+ this.box.rectangle.bottom_right_x,
+ this.box.rectangle.bottom_right_y);
+
+ this.setShape();
+ } finally {
+ lock.unlock();
+ }