Python | 4 Locks, No Branching
\nfrom threading import Lock\n\nclass ZeroEvenOdd:\n    def __init__(self, n):\n        self.n = n\n        self.zero_lock = Lock()\n        self.nonzero_lock =
```\nfrom threading import Lock\n\nclass ZeroEvenOdd:\n    def __init__(self, n):\n        self.n = n\n        self.zero_lock = Lock()\n        self.nonzero_lock = Lock()\n        self.odd_lock = Lock()\n        self.even_lock = Lock()\n        self.nonzero_lock.acquire()\n        self.even_lock.acquire()\n\n    def zero(self, printNumber: \'Callable[[int], None]\') -> None:\n        for _ in range(self.n):\n            self.zero_lock.acquire()\n            printNumber(0)\n            self.nonzero_lock.release()\n\n    def even(self, printNumber: \'Callable[[int], None]\') -> None:\n        for num in range(2, self.n+1, 2):\n            self.even_lock.acquire()\n            self.nonzero_lock.acquire()\n            printNumber(num)\n            self.zero_lock.release()\n            self.odd_lock.release()\n\n    def odd(self, printNumber: \'Callable[[int], None]\') -> None:\n        for num in range(1, self.n+1, 2):\n            self.odd_lock.acquire()\n            self.nonzero_lock.acquire()\n            printNumber(num)\n            self.zero_lock.release()\n            self.even_lock.release()\n```
['Python3']