Code example for Semaphore

Methods: acquire, release

0
 
	public void send_stop() { 
		Log.d(TAG, "in send_stop()");
		queue.clear();
		try { 
			writeLock.acquire();
			Log.d(TAG, "sending feedhold");
			write("!"); 
			Log.d(TAG, "sending {\"qf\":1}");
			write("{\"qf\":1}\n"); 
		} catch (InterruptedException e) {
			e.printStackTrace();
		} 
 
		writeLock.release();
	} 
 
	public Bundle getMotor(int m) {
		return machine.getMotorBundle(m);
	}