Java semaphores no if
\nclass ZeroEvenOdd {\n    private int n;\n    \n    private final Semaphore zeroSema = new Semaphore(1);\n    private final Semaphore oddSema = new Semaphore(2
```\nclass ZeroEvenOdd {\n    private int n;\n    \n    private final Semaphore zeroSema = new Semaphore(1);\n    private final Semaphore oddSema = new Semaphore(2);\n    private final Semaphore evenSema = new Semaphore(0);\n    \n    public ZeroEvenOdd(int n) {\n        this.n = n;\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            zeroSema.acquire(1);\n        \n            printNumber.accept(0);\n        \n            evenSema.release();\n            oddSema.release();\n        }\n    }\n    \n    public void odd(IntConsumer printNumber) throws InterruptedException {\n        for (int i = 1; i <= n; i += 2) {\n            oddSema.acquire(3);\n        \n            printNumber.accept(i);\n        \n            zeroSema.release();\n        }\n    }\n\n    public void even(IntConsumer printNumber) throws InterruptedException {\n        for (int i = 2; i <= n; i += 2) {\n            evenSema.acquire(2);\n        \n            printNumber.accept(i);\n        \n            zeroSema.release();\n            oddSema.release();\n        }\n    }\n}\n```
[]