Code example for Semaphore

Methods: availablePermits

0
 
	private boolean mRedelivery;
 
	@Override 
	public void onStart(final Intent intent, final int startId) {
		if (mSemaphore.availablePermits() > 0) {
			final Thread thread = getWorkingThread(intent, startId);
			thread.start();
		} 
	} 
 
	@Override 
	public int onStartCommand(final Intent intent, final int flags, final int startId) {
		onStart(intent, startId);
		return mRedelivery ? START_REDELIVER_INTENT : START_NOT_STICKY;
	} 
 
	public void setRedelivery(final boolean redelivery) {
		mRedelivery = redelivery;
	}