[Java] Simple solution using Semaphore, more simple than all the above solutions.
\nclass ZeroEvenOdd {\n    private int n;\n    private Semaphore zero;\n    private Semaphore odd; \n    private Semaphore even;\n    \n    public ZeroEvenOdd(i
```\nclass ZeroEvenOdd {\n    private int n;\n    private Semaphore zero;\n    private Semaphore odd; \n    private Semaphore even;\n    \n    public ZeroEvenOdd(int n) {\n        this.n = n;\n        this.zero = new Semaphore(1);\n        this.odd = new Semaphore(1);\n        this.even = new Semaphore(0);\n    }\n\n    // printNumber.accept(x) outputs "x", where x is an integer.\n    public void zero(IntConsumer printNumber) throws InterruptedException {\n        for(int i =1; i<=n; i++){\n            zero.acquire();\n            printNumber.accept(0);\n            odd.release(1);\n            even.release(1);\n        }\n    }\n\n    public void even(IntConsumer printNumber) throws InterruptedException {\n        for( int i =2; i<=n; i+=2){\n            even.acquire(2);\n            printNumber.accept(i);\n            zero.release(1);\n        }\n    }\n\n    public void odd(IntConsumer printNumber) throws InterruptedException {\n        for( int i =1; i<=n; i+=2){\n            odd.acquire(2);\n            printNumber.accept(i);\n            zero.release(1);\n        }\n    }\n}\n```
[]