Ensure ThreadPool constructor does not return until fully initialized.

Thread pool was being deleted too early during runtime shutdown,
this was causing a GC running during runtime shutdown to
occasionally reference a deleted thread pool.

Fixed an error where the thread pool was being deleted before the
threads were done attaching by making the thread pool constructor
block until all of the threads are attached.

Change-Id: I5f0884a74d78c4541ee0e582112857077f3f594f
diff --git a/src/barrier_test.cc b/src/barrier_test.cc
index 7b31e29..284be57 100644
--- a/src/barrier_test.cc
+++ b/src/barrier_test.cc
@@ -67,7 +67,7 @@
 TEST_F(BarrierTest, CheckWait) {
   Thread* self = Thread::Current();
   ThreadPool thread_pool(num_threads);
-  Barrier barrier;
+  Barrier barrier(0);
   AtomicInteger count1 = 0;
   AtomicInteger count2 = 0;
   AtomicInteger count3 = 0;
@@ -124,7 +124,7 @@
 TEST_F(BarrierTest, CheckPass) {
   Thread* self = Thread::Current();
   ThreadPool thread_pool(num_threads);
-  Barrier barrier;
+  Barrier barrier(0);
   AtomicInteger count = 0;
   const int32_t num_tasks = num_threads * 4;
   const int32_t num_sub_tasks = 128;