C++ Locks!
At this point in time I am not sure if this isn\'t optimal, but here it is.\n\nclass ZeroEvenOdd {\nprivate:\n    int n;\n    mutex m0, m_odd, m_even;\n    int 
At this point in time I am not sure if this isn\'t optimal, but here it is.\n```\nclass ZeroEvenOdd {\nprivate:\n    int n;\n    mutex m0, m_odd, m_even;\n    int cur;\n    \npublic:\n    ZeroEvenOdd(int n) {\n        this->n = n;\n        // m0.lock(); // don\'t block this one xD\n        m_odd.lock();\n        m_even.lock();\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            m0.lock(); \n            // put lock here until unlocked by anyone else\n            // continue to the next line\n            printNumber(0);\n            if (i % 2 == 0) \n                m_even.unlock();\n            else\n                m_odd.unlock();\n        }\n    }\n\n    void even(function<void(int)> printNumber) {\n        for (int i = 2; i <= n; i += 2) {\n            m_even.lock();\n            printNumber(i);\n            m0.unlock();\n        }\n    }\n\n    void odd(function<void(int)> printNumber) {\n        for (int i = 1; i <= n; i += 2) {\n            m_odd.lock();\n            printNumber(i);\n            m0.unlock();\n        }\n    }\n};\n```
['C', 'C++']