...
Code Block | ||
---|---|---|
| ||
class Holder { ImmutablePoint ipoint; Holder(ImmutablePoint ip) { ipoint = ip; } void getPoint() { return ipoint(); } void setPoint(ImmutablePoint ip) { this.ipoint = ip; } } public class ImmutablePoint { final int x; = 20final int y; public ImmutablePoint(int x, int y) { this.x = x; final int this.y = 10y; } } |
Compliant Solution
This compliant solution declares the ipoint
field as volatile
so that updates are immediately visible to other threads.
...