Java Short Solution !!!
\nimport java.util.concurrent.*;\n\nclass ZeroEvenOdd {\n    private int n;\n    Semaphore sem0, sem1, sem2;\n    public ZeroEvenOdd(int n) {\n        this.n = 
```\nimport java.util.concurrent.*;\n\nclass ZeroEvenOdd {\n    private int n;\n    Semaphore sem0, sem1, sem2;\n    public ZeroEvenOdd(int n) {\n        this.n = n;\n        sem0 = new Semaphore(1);\n        sem1 = new Semaphore(0);\n        sem2 = 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 = 0; i < n; i++) {\n            sem0.acquire();\n            printNumber.accept(0);\n            if((i & 1) == 0) {\n                sem2.release();\n            } else {\n                sem1.release();\n            }\n        }\n    }\n\n    public void even(IntConsumer printNumber) throws InterruptedException {\n        for(int i = 2; i <= n; i += 2) {\n            sem1.acquire();\n            printNumber.accept(i);\n            sem0.release();\n        }        \n    }\n\n    public void odd(IntConsumer printNumber) throws InterruptedException {\n        for(int i = 1; i <= n; i += 2) {\n            sem2.acquire();\n            printNumber.accept(i);\n            sem0.release();            \n        }        \n    }\n}\n```
[]