Short python solution with barrier that hijacks printNumber
\nimport threading\n\nclass ZeroEvenOdd:\n    def __init__(self, n):\n        self.n = n\n        self.barrier = threading.Barrier(3, lambda: self.run())\n     
```\nimport threading\n\nclass ZeroEvenOdd:\n    def __init__(self, n):\n        self.n = n\n        self.barrier = threading.Barrier(3, lambda: self.run())\n        \n    def run(self):\n        for i in range(1, self.n + 1):\n            self.print_zero(0)\n            \n            if i % 2 == 0:\n                self.print_even(i)\n            else:\n                self.print_odd(i)\n            \n\t# printNumber(x) outputs "x", where x is an integer.\n    def zero(self, printNumber: \'Callable[[int], None]\') -> None:\n        self.print_zero = printNumber\n        self.barrier.wait()    \n        \n        \n    def even(self, printNumber: \'Callable[[int], None]\') -> None:\n        self.print_even = printNumber\n        self.barrier.wait()\n        \n        \n    def odd(self, printNumber: \'Callable[[int], None]\') -> None:\n        self.print_odd = printNumber\n        self.barrier.wait()\n```
['Python', 'Python3']