python solution with threading.Events
Simple Python solution:\n\n\nimport threading\nclass FooBar(object):\n    def __init__(self, n):\n        self.n = n\n        self.foo_event = threading.Event()
Simple Python solution:\n\n```\nimport threading\nclass FooBar(object):\n    def __init__(self, n):\n        self.n = n\n        self.foo_event = threading.Event()\n        self.bar_event = threading.Event()\n\n\n    def foo(self, printFoo):\n        """\n        :type printFoo: method\n        :rtype: void\n        """\n        for i in xrange(self.n):\n            # printFoo() outputs "foo". Do not change or remove this line.\n            self.foo_event.wait()\n            printFoo()\n            self.foo_event.clear()\n            self.bar_event.set()\n\n\n    def bar(self, printBar):\n        """\n        :type printBar: method\n        :rtype: void\n        """\n\n        self.foo_event.set()\n\n        for i in xrange(self.n):         \n            self.bar_event.wait()\n            # printBar() outputs "bar". Do not change or remove this line.\n            printBar()\n            self.bar_event.clear()\n            self.foo_event.set()\n\n```
[]