[Java] Clean Java Solution using semaphore
\nclass ZeroEvenOdd {\n    private int n;\n    Semaphore s0, sEven, sOdd;\n    \n    public ZeroEvenOdd(int n) {\n        this.n = n;\n        s0 = new Semaphor
```\nclass ZeroEvenOdd {\n    private int n;\n    Semaphore s0, sEven, sOdd;\n    \n    public ZeroEvenOdd(int n) {\n        this.n = n;\n        s0 = new Semaphore(1);\n        sEven = new Semaphore(0);\n        sOdd = 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 <= this.n; i++) {\n            s0.acquire();\n            printNumber.accept(0);\n            if (i % 2 == 0) {\n                sEven.release();\n            }else {\n                sOdd.release();\n            }\n        }\n    }\n\n    public void even(IntConsumer printNumber) throws InterruptedException {\n        for (int i = 2; i <= this.n; i += 2) {\n            sEven.acquire();\n            printNumber.accept(i);\n            s0.release();\n        }\n    }\n\n    public void odd(IntConsumer printNumber) throws InterruptedException {\n        for (int i = 1; i <= this.n; i += 2) {\n            sOdd.acquire();\n            printNumber.accept(i);\n            s0.release();\n        }\n    }\n}\n```
['Java']