Wait for thread

Added new function on the thread pool. This new function wait for
all thread finish their tasks.