Code example for Semaphore

0
 
	private class RecordingThread extends Thread
	{ 
		private boolean stopped = true;
		byte[] mRecordBuffer;
		private Semaphore waitStarted = new Semaphore(0);
		private boolean sleep = false;
 
		RecordingThread() 
		{ 
			super(); 
		} 
 
		void init(int bufsize)
		{ 
			if( mRecordBuffer == null || mRecordBuffer.length != bufsize )
				mRecordBuffer = new byte[bufsize];
		} 
 
		public void run() 
		{