import java.awt.Rectangle; class MyClass { Rectangle rect = new Rectangle(1, 1, 100, 300); void doit() { int x = 504; int y = x / 3; synchronized (this) { rect.width -= x; rect.height -= y; } } }