1 | public class EvenBetterShape { |
2 | protected double x_ = 0.0; |
3 | protected double width_ = 0.0; |
4 | protected Object locationLock_ = new Object(); |
5 | protected Object dimensionLock_ = new Object(); |
6 | public double x() { |
7 | synchronized(locationLock_) { |
8 | return x_; |
9 | } |
10 | } |
11 | public double width() { |
12 | synchronized(dimensionLock_) { |
13 | return width_; |
14 | } |
15 | } |
16 | } |