Python solution using Lock
Hi, below is my python solution using Lock, feel free to give idea.\n\n\nfrom threading import Lock\nclass FooBar:\n    def __init__(self, n):\n        self.n =
Hi, below is my python solution using Lock, feel free to give idea.\n\n```\nfrom threading import Lock\nclass FooBar:\n    def __init__(self, n):\n        self.n = n\n        self.lock1 = Lock()\n        self.lock2 = Lock()\n        \n        self.lock1.acquire()\n\n\n    def foo(self, printFoo: \'Callable[[], None]\') -> None:\n        \n        for i in range(self.n):\n            self.lock2.acquire()\n            # printFoo() outputs "foo". Do not change or remove this line.\n            printFoo()\n            self.lock1.release()\n\n\n    def bar(self, printBar: \'Callable[[], None]\') -> None:\n        \n        for i in range(self.n):\n            self.lock1.acquire()\n            # printBar() outputs "bar". Do not change or remove this line.\n            printBar()\n            self.lock2.release()\n\n```
['Python', 'Python3']