Code example for AtomicReference

Methods: getset

	private LocationManagerWrapper() {} 
	//protect the reference as an AtomicReference 
	private static final AtomicReference<LocationManager> singleton = new AtomicReference<LocationManager>();
	public static LocationManager get() {
		LocationManager impl = LocationManagerWrapper.singleton.get();
		if(impl == null) {
			LocationManagerWrapper.singleton.set(new LocationManagerWrapper());
			impl = LocationManagerWrapper.singleton.get();
		return impl;
	// Define a listener that responds to location updates 
	private LocationListener locationListener = new LocationListener() {
	    public void onLocationChanged(Location location) { 
	      // Called when a new location is found by the network location provider