Fix race between Thread ctor/dtor and MessageQueueManager registrations.

This CL fixes a race where for Thread objects the parent MessageQueue
constructor registers the object in the MessageQueueManager even though
the Thread is not constructed completely yet. Same happens during
destruction.

BUG=webrtc:1225

Review URL: https://codereview.webrtc.org/1666863002

Cr-Commit-Position: refs/heads/master@{#11497}
diff --git a/webrtc/base/thread.cc b/webrtc/base/thread.cc
index 4197d28..cda4ba4 100644
--- a/webrtc/base/thread.cc
+++ b/webrtc/base/thread.cc
@@ -138,8 +138,8 @@
   thread_->SetAllowBlockingCalls(previous_state_);
 }
 
-Thread::Thread(SocketServer* ss)
-    : MessageQueue(ss),
+Thread::Thread(SocketServer* ss, bool init_queue)
+    : MessageQueue(ss, false),
       running_(true, false),
 #if defined(WEBRTC_WIN)
       thread_(NULL),
@@ -148,11 +148,14 @@
       owned_(true),
       blocking_calls_allowed_(true) {
   SetName("Thread", this);  // default name
+  if (init_queue) {
+    DoInit();
+  }
 }
 
 Thread::~Thread() {
   Stop();
-  Clear(NULL);
+  DoDestroy();
 }
 
 bool Thread::SleepMs(int milliseconds) {