C++: 🚀 😎 One-line Solution with `std::atomic`
Intuition\nWe use a variable (turn) to keep track of turns.\n\n# Approach\nWe use std::atomic to prevent data race. Plus, we use yield to prevent busy waiting.\
# Intuition\nWe use a variable (`turn`) to keep track of turns.\n\n# Approach\nWe use `std::atomic` to prevent data race. Plus, we use `yield` to prevent busy waiting.\n\n# Code\n```\nclass Foo {\n    std::atomic<int> turn = 1;\npublic:\n    Foo() {\n        \n    }\n\n    void first(function<void()> printFirst) {\n        while(turn!=1)\n            this_thread::yield();\n        // printFirst() outputs "first". Do not change or remove this line.\n        printFirst();\n        turn++;\n    }\n\n    void second(function<void()> printSecond) {\n        while(turn!=2)\n            this_thread::yield();\n        // printSecond() outputs "second". Do not change or remove this line.\n        printSecond();\n        turn++;\n    }\n\n    void third(function<void()> printThird) {\n        while(turn!=3)\n            this_thread::yield();\n        // printThird() outputs "third". Do not change or remove this line.\n        printThird();\n    }\n};\n```
['C++']