Fix thread pool test valgrind flakiness

The test used to use the counters to see when the tasks were done
but since the counter is incremented before finalize was called, the
test would sometimes finish before the objects were freed. This
resulted in valgrind leaks.

Change-Id: I6dc3cf6a155cde3af5d06b1416773a6ae6f2a6e6
diff --git a/runtime/thread_pool_test.cc b/runtime/thread_pool_test.cc
index 4bd44dc..d5f17d1 100644
--- a/runtime/thread_pool_test.cc
+++ b/runtime/thread_pool_test.cc
@@ -95,11 +95,7 @@
   EXPECT_EQ(0, bad_count.LoadSequentiallyConsistent());
   // Allow tasks to finish up and delete themselves.
   thread_pool.StartWorkers(self);
-  while (count.LoadSequentiallyConsistent() != num_tasks &&
-      bad_count.LoadSequentiallyConsistent() != 1) {
-    usleep(200);
-  }
-  thread_pool.StopWorkers(self);
+  thread_pool.Wait(self, false, false);
 }
 
 class TreeTask : public Task {