Warn if a thread attaches without a name and blow up if a thread detaches while running.

Also don't crash if a thread attaches without a name. Doing so is allowed, even
if it's not a good idea.

Change-Id: If5796af689e9221ce21f443023b0d793a8be15b0
diff --git a/src/thread.cc b/src/thread.cc
index dea554f..8bd7bc2 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -415,8 +415,10 @@
     self->CreatePeer(thread_name, as_daemon, thread_group);
   } else {
     // These aren't necessary, but they improve diagnostics for unit tests & command-line tools.
-    self->name_->assign(thread_name);
-    ::art::SetThreadName(thread_name);
+    if (thread_name != NULL) {
+      self->name_->assign(thread_name);
+      ::art::SetThreadName(thread_name);
+    }
   }
 
   self->GetJniEnv()->locals.AssertEmpty();