thread-pool: fix waiting until all tasks are complete.

Change-Id: Iaf5a3bf28879f229a223a8760fd878f96958a53c