voidfirst(function<void()> printFirst) { // printFirst() outputs "first". Do not change or remove this line. printFirst(); sem_post(&sem_pthread_2); }
voidsecond(function<void()> printSecond) { sem_wait(&sem_pthread_2); // printSecond() outputs "second". Do not change or remove this line. printSecond(); sem_post(&sem_pthread_3); }
voidthird(function<void()> printThird) { sem_wait(&sem_pthread_3); // printThird() outputs "third". Do not change or remove this line. printThird(); } };
publicvoidfirst(Runnable printFirst)throws InterruptedException { // printFirst.run() outputs "first". Do not change or remove this line. printFirst.run(); sem_thread_2.release(); }
publicvoidsecond(Runnable printSecond)throws InterruptedException { sem_thread_2.acquire(); // printSecond.run() outputs "second". Do not change or remove this line. printSecond.run(); sem_thread_3.release(); }
publicvoidthird(Runnable printThird)throws InterruptedException { sem_thread_3.acquire(); // printThird.run() outputs "third". Do not change or remove this line. printThird.run(); } }
deffirst(self, printFirst: 'Callable[[], None]') -> None: # printFirst() outputs "first". Do not change or remove this line. printFirst() self.sem_thread_s2.release()
defsecond(self, printSecond: 'Callable[[], None]') -> None: self.sem_thread_s2.acquire() # printSecond() outputs "second". Do not change or remove this line. printSecond() self.sem_thread_s3.release()
defthird(self, printThird: 'Callable[[], None]') -> None: self.sem_thread_s3.acquire() # printThird() outputs "third". Do not change or remove this line. printThird()
voidfirst(function<void()> printFirst) { // printFirst() outputs "first". Do not change or remove this line. printFirst(); lock_2.unlock(); }
voidsecond(function<void()> printSecond) { lock_2.lock(); // printSecond() outputs "second". Do not change or remove this line. printSecond(); lock_3.unlock(); }
voidthird(function<void()> printThird) { lock_3.lock(); // printThird() outputs "third". Do not change or remove this line. printThird(); } };
deffirst(self, printFirst: 'Callable[[], None]') -> None: # printFirst() outputs "first". Do not change or remove this line. printFirst() self.lock_s2.release()
defsecond(self, printSecond: 'Callable[[], None]') -> None: self.lock_s2.acquire() # printSecond() outputs "second". Do not change or remove this line. printSecond() self.lock_s3.release()
defthird(self, printThird: 'Callable[[], None]') -> None: self.lock_s3.acquire() # printThird() outputs "third". Do not change or remove this line. printThird()