C++ EASY AND CLEAN CODE
Code\n\nclass FooBar {\nprivate:\n    int n;\n    mutex m1,m2;\npublic:\n    FooBar(int n) {\n        this->n = n;\n        m2.lock();\n    }\n    void foo(func
# Code\n```\nclass FooBar {\nprivate:\n    int n;\n    mutex m1,m2;\npublic:\n    FooBar(int n) {\n        this->n = n;\n        m2.lock();\n    }\n    void foo(function<void()> printFoo) {\n        for (int i = 0; i < n; i++) {\n            m1.lock();\n        \tprintFoo();\n            m2.unlock();\n        }\n    }\n    void bar(function<void()> printBar) {\n        for (int i = 0; i < n; i++) {\n            m2.lock();\n        \tprintBar();\n            m1.unlock();\n        }\n    }\n};\n```
['C++']