[Java] Easy soln using 3 semaphores
\nclass ZeroEvenOdd {\n        private int n;\n        Semaphore zer, eve, odd;\n        public ZeroEvenOdd(int n) {\n            this.n = n;\n            zer =
```\nclass ZeroEvenOdd {\n        private int n;\n        Semaphore zer, eve, odd;\n        public ZeroEvenOdd(int n) {\n            this.n = n;\n            zer = new Semaphore(1);\n            eve = new Semaphore(0);\n            odd = 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                zer.acquire();\n                printNumber.accept(0);\n                if (i % 2 == 0) {\n                    eve.release();\n                } else {\n                    odd.release();\n                }\n            }\n        }\n\n        public void even(IntConsumer printNumber) throws InterruptedException {\n            for (int i = 2; i <= n; i += 2) {\n                eve.acquire();\n                printNumber.accept(i);\n                zer.release();\n            }\n        }\n\n        public void odd(IntConsumer printNumber) throws InterruptedException {\n            for (int i = 1; i <= n; i += 2) {\n                odd.acquire();\n                printNumber.accept(i);\n                zer.release();\n            }\n        }\n    }\n```
[]