[Java]Beat 100% solution, easy understood
\nclass ZeroEvenOdd {\n    private int n;\n    private int count;\n    private Semaphore s0, s1, s2;\n    \n    public ZeroEvenOdd(int n) {\n        this.n = n;
```\nclass ZeroEvenOdd {\n    private int n;\n    private int count;\n    private Semaphore s0, s1, s2;\n    \n    public ZeroEvenOdd(int n) {\n        this.n = n;\n        count = 0;\n        s0 = new Semaphore(1);\n        s1 = new Semaphore(0);\n        s2 = 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            s0.acquire();\n            printNumber.accept(0);\n            count++;\n            if (count % 2 == 1) {\n                s1.release();\n            } else {\n                s2.release();\n            }\n        }\n    }\n\n    public void even(IntConsumer printNumber) throws InterruptedException {\n        \n        for (int i = 0; i < n/2; i++) {\n            s2.acquire();\n            printNumber.accept(count);\n            s0.release();\n        }\n        \n    }\n\n    public void odd(IntConsumer printNumber) throws InterruptedException {\n        for (int i = 0; i < Math.ceil((double)n/2); i++) {\n            s1.acquire();\n            printNumber.accept(count);\n            s0.release();\n        }\n    }\n}\n```
[]