svoid test_ThreadPool() { new ThreadPool pool; print(pool); flagTest(flag -> pool.acquireThread((Runnable) flag), 10.0); print(pool); int n = pool.maxSize()*2; new IntVar counter; new IntVar waitCounter; pool.onCustomerMustWaitAlert(-> inc(waitCounter)); for immutable i to n: { var t = pool.acquireThread(r { sleepSeconds((i+1)*0.2); printWithMS(this + " done"); inc(counter); }); printWithMS("Acquired thread " + t); } counter.waitForValue(n); assertEquals(4, waitCounter!); print(pool); }