C++ condition_variable solution
\nclass ZeroEvenOdd {\nprivate:\n    int n;\n    mutex mx;\n    condition_variable cv;\n    atomic<int> num_to_print;\n    atomic<int> current;\n\npublic:\n    
```\nclass ZeroEvenOdd {\nprivate:\n    int n;\n    mutex mx;\n    condition_variable cv;\n    atomic<int> num_to_print;\n    atomic<int> current;\n\npublic:\n    ZeroEvenOdd(int n) {\n        this->n = n;\n        num_to_print = 0;\n        current = 0;\n    }\n\n    // printNumber(x) outputs "x", where x is an integer.\n    void zero(function<void(int)> printNumber) {\n        do_work(printNumber, [&]{return num_to_print == 0;});\n    }\n\n    void even(function<void(int)> printNumber) {\n        do_work(printNumber, [&]{return num_to_print != 0 && num_to_print % 2 == 0;});\n    }\n\n    void odd(function<void(int)> printNumber) {\n         do_work(printNumber, [&]{return num_to_print % 2 != 0;});\n    }\n    \nprotected:\n   void do_work(function<void(int)> print, function<bool()> eval)\n    {\n        while(current <= n)\n        {\n            unique_lock<mutex> ul(mx);\n            cv.wait(ul, [&]{return eval() || current > n;});\n            if(current > n) break;\n            print(num_to_print);\n            num_to_print = num_to_print == 0 || num_to_print == n ? ++current : 0;\n            cv.notify_all();\n        }\n    }\n};\n```
['C']