Code example for AtomicBoolean

Methods: compareAndSet

0
	public void onStart(Intent intent, int startId) {
		Log.d(TAG,"STARTING: " + startId + " " + intent);
		super.onStart(intent, startId);
		this.startID = startId;
		 
		if ( ! started.compareAndSet(false, true) )
			Log.w(TAG, "Already started!");
 
		if ( intent == null ) {
			Log.w(TAG, "Null intent; don't know what to do!");
			this.stopSelf(this.startID);
			return; 
		} 
			 
		final String action = intent.getAction();
		if ( Intent.ACTION_RUN.equals(action) ) {
			// schedule the recurring service then quit immediately. 
			scheduleSync(); 
		} 
		else if ( Intent.ACTION_SHUTDOWN.equals(action) ) {
			Log.d(TAG,"SHUTTING DOWN");