Easy C# Solution with 2 AutoResetEvents
\nusing System.Threading;    \n\npublic class FooBar\n    {\n        private int n;\n        private readonly AutoResetEvent _fooEventWaitHandle;\n        priva
```\nusing System.Threading;    \n\npublic class FooBar\n    {\n        private int n;\n        private readonly AutoResetEvent _fooEventWaitHandle;\n        private readonly AutoResetEvent _barEventWaitHandle;\n\n        public FooBar(int n)\n        {\n            this.n = n;\n            _fooEventWaitHandle = new AutoResetEvent(true);\n            _barEventWaitHandle = new AutoResetEvent(false);\n        }\n\n        public void Foo(Action printFoo)\n        {\n\n            for (int i = 0; i < n; i++)\n            {\n                _fooEventWaitHandle.WaitOne();\n                // printFoo() outputs "foo". Do not change or remove this line.\n                printFoo();\n                _barEventWaitHandle.Set();\n            }\n        }\n\n        public void Bar(Action printBar)\n        {\n\n            for (int i = 0; i < n; i++)\n            {\n                _barEventWaitHandle.WaitOne();\n                // printBar() outputs "bar". Do not change or remove this line.\n                printBar();\n                _fooEventWaitHandle.Set();\n            }\n        }\n    }\n```
[]