python3 solution via threading.Event | 36 ms 13 MB
\nfrom threading import Event\n\n\nclass Foo:\n    def __init__(self):\n\t\t# Initialize events for threads\n        self.event1 = Event()\n        self.event2 
```\nfrom threading import Event\n\n\nclass Foo:\n    def __init__(self):\n\t\t# Initialize events for threads\n        self.event1 = Event()\n        self.event2 = Event()\n        \n\n    def first(self, printFirst: \'Callable[[], None]\') -> None:\n        printFirst()\n\t\t# set flag\n        self.event1.set()\n\n\n    def second(self, printSecond: \'Callable[[], None]\') -> None:\n        # wait for flag\n\t\tself.event1.wait()\n        printSecond()\n\t\t# set flag\n        self.event2.set()\n\n\n    def third(self, printThird: \'Callable[[], None]\') -> None:\n        # wait for flag\n\t\tself.event2.wait()\n        printThird()\n```
['Python', 'Python3']