🚀Easy C++ Solution🚀 :
\n# Code\n\nclass ZeroEvenOdd {\nprivate:\n    int n;\n    int x;\n    int turn;\n    mutex m;\n    condition_variable cv;\npublic:\n    ZeroEvenOdd(int n) {\n 
\n# Code\n```\nclass ZeroEvenOdd {\nprivate:\n    int n;\n    int x;\n    int turn;\n    mutex m;\n    condition_variable cv;\npublic:\n    ZeroEvenOdd(int n) {\n        this->n = n;\n        x = 1;\n        turn = 0; \n    }\n\n    // printNumber(x) outputs "x", where x is an integer.\n    void zero(function<void(int)> printNumber) {\n        for(int i =1;i<=n;i++)\n        {\n            unique_lock <mutex> lock(m);\n            while((turn ==1 or turn ==2 )and i<=n)\n                cv.wait(lock);\n            if(i<=n)\n            {\n                printNumber(0);\n                if(x %2 == 1)\n                    turn = 1;\n                else\n                    turn = 2;\n            }\n            else\n                break;\n            cv.notify_all();\n\n        }\n    }\n\n    void even(function<void(int)> printNumber) {\n        for(int i =1;i<=n/2;i++)\n        {\n            unique_lock <mutex> lock(m);\n            while((turn ==1 or turn == 0 )and i<=n/2)\n                cv.wait(lock);\n            if(i<=n/2)\n            {\n                printNumber(x);\n                x++;\n                turn = 0;\n            }\n            else\n                break;\n            cv.notify_all();\n\n        }\n    }\n\n    void odd(function<void(int)> printNumber) {\n        for(int i =1;i<=(n+1)/2;i++)\n        {\n            unique_lock <mutex> lock(m);\n            while((turn == 0 or turn ==2) and i<=(n+1)/2)\n                cv.wait(lock);\n            if(i<=(n+1)/2)\n            {\n                printNumber(x);\n                x++;\n                turn = 0;\n            }\n            else\n                break;\n            cv.notify_all();\n\n        }\n    }\n};\n```
['Concurrency', 'C++']