threadpool: clear the exceptions queue in wait()

Updated ThreadPool.wait() to drain all exceptions out of the exception
queue everytime it raises a ThreadPoolException. This keeps the
exception queue from potentially growing endlessly and also prevents
raising old exceptions.