sclass ThreadPool { int max = numberOfCores(); new SelfNotifyingSet used; new SelfNotifyingSet free; synchronized int total() { ret l(used)+l(free); } synchronized bool nonFree() { ret empty(free) && max < total(); } event fireCustomerMustWaitAlert; synchronized Thread acquireThread() { if (nonFree()) fireCustomerMustWaitAlert(); sleepWhileEmpty(free); } }