Code example for Semaphore

Methods: acquire, release

0
             * This semaphore ensures that only one instance at a time 
             * accesses EGL. 
             */ 
            try { 
                try { 
                sEglSemaphore.acquire();
                } catch (InterruptedException e) {
                    return; 
                } 
                guardedRun(); 
            } catch (InterruptedException e) {
                // fall thru and exit normally 
            } finally { 
                sEglSemaphore.release();
            } 
        } 
 
        private void guardedRun() throws InterruptedException { 
            mEglHelper = new EglHelper();
            /* 
             * Specify a configuration for our opengl session