How can you ensure that program threads with common instance access - defined below in Coordinates class, could not read coordinates in an inconsistent state, that is between two commands of the setXY method? Solution in case you can modify the class - coordinates or even if you can't.
public class Coordinates {
 int x, y;
 public int[] getXY() {return new int[]{x, y};}
 public void setXY(int x, int y) {
 this.x = x;
 this.y = y;
 }
}
 
     
    