using System.Collections.Generic;
using System.Threading.Tasks;
private volatile bool foo = true;
for (int i = 0; i < n; ++i) {
for (int i = 0; i < n; ++i) {
public static void Main() {
var fooBar = new FooBar(5);
var tasks = new List<Task>();
tasks.Add(Task.Run(() => fooBar.Bar()));
tasks.Add(Task.Run(() => fooBar.Foo()));
Task.WaitAll(tasks.ToArray());