switch Thread to using an atomic bool instead of abusing a mutex

Change-Id: Ie39649922a8a35a40fcef57647716da3c50766a7
diff --git a/aos/common/util/thread.cc b/aos/common/util/thread.cc
index dbb638e..bfb1f51 100644
--- a/aos/common/util/thread.cc
+++ b/aos/common/util/thread.cc
@@ -24,10 +24,7 @@
 void Thread::Join() {
   CHECK(!joined_ && started_);
   joined_ = true;
-  {
-    MutexLocker locker(&should_terminate_mutex_);
-    should_terminate_ = true;
-  }
+  should_terminate_.store(true);
   CHECK(pthread_join(thread_, NULL) == 0);
 }
 
diff --git a/aos/common/util/thread.h b/aos/common/util/thread.h
index 97123d5..80b45e1 100644
--- a/aos/common/util/thread.h
+++ b/aos/common/util/thread.h
@@ -2,8 +2,10 @@
 #define AOS_COMMON_UTIL_THREAD_H_
 
 #include <functional>
+#include <atomic>
 
-#include "aos/common/mutex.h"
+#include <pthread.h>
+
 #include "aos/common/macros.h"
 
 namespace aos {
@@ -30,8 +32,7 @@
   // Subclasses need to call this periodically if they are going to loop to
   // check whether they have been asked to stop.
   bool should_continue() {
-    MutexLocker locker(&should_terminate_mutex_);
-    return !should_terminate_;
+    return !should_terminate_.load();
   }
 
  private:
@@ -46,8 +47,7 @@
   pthread_t thread_;
   bool started_;
   bool joined_;
-  bool should_terminate_;
-  Mutex should_terminate_mutex_;
+  ::std::atomic_bool should_terminate_;
 
   DISALLOW_COPY_AND_ASSIGN(Thread);
 };