Code example for AtomicReference

0
    private volatile long lastTimeMs = -1;
	 
	public final Object LOCK = new Object();
	 
	private AtomicReference<Vibrator> vibratorRef =
		new AtomicReference<Vibrator>();
	 
	public BouncingBallModel(int ballRadius) {
		this.ballRadius = ballRadius;
	} 
	 
	public void setAccel(float ax, float ay) {
		synchronized (LOCK) {
			this.accelX = ax;
			this.accelY = ay;
		} 
	} 
	 
	public void setSize(int width, int height) {
		synchronized (LOCK) {
			this.pixelWidth = width;