[leetcode][Python][Concurrency][Medium] 1115. Print FooBar Alternately

1 · ZhengWei, Liu · Dec. 24, 2022, 4:07 a.m.
Description Suppose you are given the following code: class FooBar { public void foo() { for (int i = 0; i < n; i++) { print("foo"); } } public void bar() { for (int i = 0; i < n; i++) { print("bar"); } } } The same instance of FooBar will be passed to two different threads: thread A will call foo(), while thread B will call bar(). Modify the given program to output "foobar" n times....