public class PointDriver { public static void main(String[] args) { /* We have a mutable Point class. What could go wrong * if we try to intern such points? */ Point p1 = Point.getInstance(3, 5); Point p2 = Point.getInstance(3, 5); System.out.println("p1 is " + p1); System.out.println("p2 is " + p2); System.out.println("p1 and p2 are the same object: " + (p1 == p2)); // pretend some other thread calls the next line p1.x = 89; Point p1After = Point.getInstance(3, 5); System.out.println("p1After is " + p1); } }