Code example for Semaphore

Methods: acquire, release

0
	} 
	 
	public void send_flush() { 
			try { 
				if (!paused)
					writeLock.acquire();
				Log.d(TAG, "sending queue flush");
				write("%"); 
				ioLog.write("* ", "%\n");
				 
				Log.d(TAG, "permits: " + serialBufferAvail.availablePermits());
				int inuse = TINYG_BUFFER_SIZE - serialBufferAvail.availablePermits();
				if (inuse > 0)
					serialBufferAvail.release(inuse);
				if (!queue.isEmpty()) {
					queue.clear();
					flushed = true;
				} 
				paused = false;
				writeLock.release();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block 
				e.printStackTrace();
			} 
	}