Easy to understand solution in Java | 7ms, beats 99.86%
\nclass ZeroEvenOdd {\n    private int n;\n    private boolean flag = true;\n    private int count=1;\n    public ZeroEvenOdd(int n) {\n        this.n = n;\n   
```\nclass ZeroEvenOdd {\n    private int n;\n    private boolean flag = true;\n    private int count=1;\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        while(count<=n)\n        { \n        synchronized(this)\n        {    \n            while(!flag)\n                wait();\n            if(count<=n)\n                printNumber.accept(0);\n           flag=false;\n            notifyAll();\n        }\n        }    \n    }\n\n    public void even(IntConsumer printNumber) throws InterruptedException {\n        while(count<=n)\n        {    \n        synchronized(this)\n        {    \n            while(flag || count%2!=0)\n                wait();\n            \n           if(count<=n)\n               printNumber.accept(count);\n           \n            flag=true;\n            count++;\n            notifyAll();\n        }\n        }\n    }\n\n    public void odd(IntConsumer printNumber) throws InterruptedException {\n        while(count<=n)\n        {\n        synchronized(this)\n        {    \n            while(flag || count%2==0)\n                wait();\n           if(count<=n)\n               printNumber.accept(count);\n           flag=true;\n            count++;\n            notifyAll();\n        }\n        }    \n    }\n}\n```
['Java']