Semaphore solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nusing System.Threading;\n\npublic class Foo {\n\n    private static Semaphore s1;\n    private static Semaphore s2;\n\n    public Foo() {\n        s1 = new Semaphore(initialCount: 0, maximumCount: 1);\n        s2 = new Semaphore(initialCount: 0, maximumCount: 1);\n    }\n\n    public void First(Action printFirst) {\n        \n        printFirst();\n        s1.Release();\n    }\n\n    public void Second(Action printSecond) {\n        \n        s1.WaitOne();\n        printSecond();\n        s2.Release();\n    }\n\n    public void Third(Action printThird) {\n        s2.WaitOne();\n        printThird();\n    }\n}\n```
['C#']