Code example for Semaphore

Methods: release

0
            @Override 
            public void run() { 
                try { 
                    command.run();
                } finally { 
                    sem.release();
                } 
            } 
        }); 
        if (! sem.tryAcquire(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) {
            fail("Failed to run the command on the looper.");
        } 
    } 
 
    private final class CameraErrorCallback implements android.hardware.Camera.ErrorCallback {
        public void onError(int error, android.hardware.Camera camera) {
            fail(String.format("Camera error, code: %d", error));
        } 
    } 
 
    private final class RecorderErrorCallback implements MediaRecorder.OnErrorListener {