luoheng
12/25/2019 - 2:35 AM

Foo

from threading import Semaphore
class Foo:
    def __init__(self):
        self.sec = Semaphore(0)
        self.thr = Semaphore(0)


    def first(self, printFirst: 'Callable[[], None]') -> None:
        # printFirst() outputs "first". Do not change or remove this line.
        printFirst()
        self.sec.release()


    def second(self, printSecond: 'Callable[[], None]') -> None:
        self.sec.acquire()
        # printSecond() outputs "second". Do not change or remove this line.
        printSecond()
        self.thr.release()

    def third(self, printThird: 'Callable[[], None]') -> None:
        self.thr.acquire()
        # printThird() outputs "third". Do not change or remove this line.
        printThird()