C#, Semaphores, faster than 100%
Code\n\nusing System.Threading;\npublic class FooBar \n{\n    private Semaphore fooSem, barSem; \n    private int n;\n    public FooBar(int n) \n    {\n        
# Code\n```\nusing System.Threading;\npublic class FooBar \n{\n    private Semaphore fooSem, barSem; \n    private int n;\n    public FooBar(int n) \n    {\n        this.n = n;\n        fooSem = new Semaphore(1, 1);\n        barSem = new Semaphore(0, 1);\n    }\n\n    public void Foo(Action printFoo) \n    {\n        for (int i = 0; i < n; i++) \n        {\n            fooSem.WaitOne();\n        \tprintFoo();\n            barSem.Release();\n        }\n    }\n\n    public void Bar(Action printBar) \n    {\n        for (int i = 0; i < n; i++) \n        {\n            barSem.WaitOne();\n        \tprintBar();\n            fooSem.Release();\n        }\n    }\n}\n```
['C#']