Threads Module User's Guide : PART II Concurrency Packages : Chapter 3 The Threading Package : The Server Classes : Resizing a Server Pool
Resizing a Server Pool
Use the resize() member to change the number of runnable servers maintained with a pool. This function does not wait for the server to contract the pool, it merely starts the process.
Contracting a Server Pool
Calling resize() to contract a server pool causes the server pool thread to attempt to stop and join with enough runnable servers to shrink the pool down to the new size. Each runnable server being stopped only does so after completing execution of any enqueued runnables. Should a sufficient number of runnable servers within the pool be deadlocked or running in an infinite loop, then the server pool can never complete its contraction of the pool, and so will no longer process enqueued runnables. A server pool in this condition can still be canceled.
Creating or Expanding a Server Pool
If the server pool experiences failure while attempting to create or start a new runnable server for the pool, then the server pool attempts to shut down all threads in the pool and exits with an exception. Since the pool expansion is performed by the server pool thread, this type of failure can occur at any time, asynchronous to any call to start() or resize(). To detect this kind of failure, periodically test the completion state of the server pool or register a callback for the RW_THR_EXCEPTION state.