def pool(currentLimit, threadFactory=Thread):
 def startThread(target):
  return threadFactory(target=target).start()
 def limitedWorkerCreator():
  stats = team.statistics()
  if ((stats.busyWorkerCount + stats.idleWorkerCount) >= currentLimit()):
   return None
  return ThreadWorker(startThread, Queue())
 team = Team(coordinator=LockWorker(Lock(), LocalStorage()), createWorker=limitedWorkerCreator, logException=err)
 return team

def pool ( currentLimit , threadFactory = Thread ) : def startThread ( target ) : return threadFactory ( target = target ) . start ( ) def limitedWorkerCreator ( ) : stats = team . statistics ( ) if ( ( stats . busyWorkerCount + stats . idleWorkerCount ) >= currentLimit ( ) ) : return None return ThreadWorker ( startThread , Queue ( ) ) team = Team ( coordinator = LockWorker ( Lock ( ) , LocalStorage ( ) ) , createWorker = limitedWorkerCreator , logException = err ) return team
construct a l{team} that spawns threads as a thread pool .