C++ Solution using condition_variable and mutex
```\nclass ZeroEvenOdd {\nprivate:\n    int n;\n    int count=0;\n    mutex mtx;\n    condition_variable cv;\n\npublic:\n    ZeroEvenOdd(int n) {\n        this-
```\nclass ZeroEvenOdd {\nprivate:\n    int n;\n    int count=0;\n    mutex mtx;\n    condition_variable cv;\n\npublic:\n    ZeroEvenOdd(int n) {\n        this->n = n;\n    }\n\n    // printNumber(x) outputs "x", where x is an integer.\n    void zero(function<void(int)> printNumber) {\n        while(count<2*n){\n            unique_lock<mutex>lck(mtx);\n            cv.wait(lck, [this]{return (count%2==0);});\n            if(count<2*n)\n            printNumber(0);\n            count++;\n            lck.unlock();\n            cv.notify_all();\n        }\n    }\n\n    void even(function<void(int)> printNumber) {\n        while(count<2*n){\n            unique_lock<mutex>lck(mtx);\n            cv.wait(lck, [this]{return (count%2!=0 && ((count+1)/2)%2==0);});\n            if(count<2*n)\n            printNumber((count+1)/2);\n            count++;\n            lck.unlock();\n            cv.notify_all();\n        }\n    }\n\n    void odd(function<void(int)> printNumber) {\n        while(count<2*n){\n            unique_lock<mutex>lck(mtx);\n            cv.wait(lck, [this]{return (count%2!=0 && ((count+1)/2)%2==1);});\n            if(count<2*n)\n            printNumber((count+1)/2);\n            count++;\n            lck.unlock();\n            cv.notify_all();\n        }\n    }\n};
[]