title: python create single thread to do one task then quit
body: <p>I am runing a web project.<br>
  I want to start a thread to do one job if some event happen.<br>
  Before,I always write multithreading program.Such as below<br></p>
  
  <pre><code>class FetchThread(threading.Thread):
      def __init__(self, profile_queue):
          ....
      def run(self):
          while true:
          ....
  </code></pre>
  
  <p>But here is only one task,I don't want a thread running all the time.<br>
  I want the thread just do one thing, then quit.But I always see others write <code>while True</code>  in <code>Thread.run</code>, I don't know if method 2 is a good way .Anyone can help?</p>
  
  <p>1.</p>
  
  <pre><code>class FetchThread(threading.Thread):
      def __init__(self, profile_queue):
          ....
      def stop(self):
          self.__running = False
      def run(self):
          while self.__running:
          ....
          self.stop()
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>class FetchThread(threading.Thread):
      def __init__(self, profile_queue):
          ....
      def run(self):
          ....
  </code></pre>