Code example for AtomicReference

Methods: compareAndSet, get

0
 
	/**  
	 * Get a PhotoConfig instance. 
	 */ 
	public static PhotoConfig getInstance() { 
		PhotoConfig rv=instanceRef.get();
		if(rv == null) {
			rv=new PhotoConfig();
			instanceRef.compareAndSet(null, rv);
		} 
		return(rv);
	} 
 
	private static void killInstance() { 
		instanceRef.set(null);
	} 
 
	/** 
	 * Set the configuration location for all future instances of 
	 * PhotoConfig. 
	 */