Java Phaser solution
\nimport java.util.concurrent.Phaser;\nclass ZeroEvenOdd {\n    private int n;\n    private Phaser phaser;\n    public ZeroEvenOdd(int n) {\n        this.n = n;
```\nimport java.util.concurrent.Phaser;\nclass ZeroEvenOdd {\n    private int n;\n    private Phaser phaser;\n    public ZeroEvenOdd(int n) {\n        this.n = n;\n        phaser = new Phaser(3);\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            printNumber.accept(0);\n            phaser.arriveAndAwaitAdvance();\n            phaser.arriveAndAwaitAdvance();\n        }\n\n    }\n\n    public void even(IntConsumer printNumber) throws InterruptedException {\n        int even=2;\n        for(int i=0;i<n;i++){\n            phaser.arriveAndAwaitAdvance();\n            if(i%2==1){\n               printNumber.accept(even);\n               even+=2; \n            }\n            phaser.arriveAndAwaitAdvance();\n        }\n    }\n\n    public void odd(IntConsumer printNumber) throws InterruptedException {\n        int odd=1;\n        for(int i=0;i<n;i++){\n            phaser.arriveAndAwaitAdvance();\n            if(i%2==0){\n               printNumber.accept(odd);\n               odd+=2; \n            }\n            phaser.arriveAndAwaitAdvance();\n        }\n    }\n}\n```
[]