pythonic
\nfrom threading import Lock\n\n\nclass ZeroEvenOdd:\n    def __init__(self, n):\n        self.n = n\n        self.lock0 = Lock()\n        self.lock1 = Lock()\n
```\nfrom threading import Lock\n\n\nclass ZeroEvenOdd:\n    def __init__(self, n):\n        self.n = n\n        self.lock0 = Lock()\n        self.lock1 = Lock()\n        self.lock2 = Lock()\n        self.lock1.acquire()\n        self.lock2.acquire()\n\n    # printNumber(x) outputs "x", where x is an integer.\n\n    def zero(self, printNumber: \'Callable[[int], None]\') -> None:\n        lock = {\n            0: self.lock1,\n            1: self.lock2,\n        }\n        for i in range(self.n):\n            self.lock0.acquire()\n            printNumber(0)\n            lock[i % 2].release()\n\n    def odd(self, printNumber: \'Callable[[int], None]\') -> None:\n        for i in range(1, self.n + 1, 2):\n            self.lock1.acquire()\n            printNumber(i)\n            self.lock0.release()\n\n    def even(self, printNumber: \'Callable[[int], None]\') -> None:\n        for i in range(2, self.n + 1, 2):\n            self.lock2.acquire()\n            printNumber(i)\n            self.lock0.release()\n\n```
[]