def setThreadPool(threadPool):
  """Set the default thread pool to use for executing new tasks.

  @param threadPool: The new default thread pool.

  @return: The previous default thread pool. This is intially None.
  """

  global _threadPool, _threadPoolLock

  _threadPoolLock.acquire()
  try:
    oldThreadPool = _threadPool
    _threadPool = threadPool
  finally:
    _threadPoolLock.release()

  return oldThreadPool