title: Understanding thread.join(timeout)
body: <p>So <strong>the <em>timeout</em> param, for a thread, should stop the thread after <em>timeout</em> seconds</strong> (if it hasn't terminated yet).</p>
  
  <p>In my software I'm trying to replace a <em>Queue.Queue.join()</em> (it contains an item for every thread: each thread will run Queue.Queue.task_done()) that could stop the software if a thread doesn't terminate. So if a thread, among other 50, doesn't terminate then it is all freezed.</p>
  
  <p><strong>I want that every thread stops in 5 seconds</strong>, for example. So i will start each thread with timeout of 5 seconds. Is it correct?</p>
  
  <p><strong>CODE</strong> </p>
  
  <pre><code>import threading
  import time
  
  def tt(name, num):
      while True:
          num += 0.5
          print 'thread ' + str(name) + ' at time ' + str(num)
          time.sleep(0.5)
  
  
  for i in range(3):
      t=threading.Thread(target=tt, args=(i, 0))
      t.setDaemon(True)
      t.start()
      t.join(timeout=1)
  
  print 'end'
  </code></pre>
  
  <p><strong>RESULT</strong></p>
  
  <p>It is not properly working.. every thread should stop after 1 second. Thread 0 stops after 3 secs, thread 1 after 2 secs. </p>
  
  <pre><code>thread 0 at time 0.5
  thread 0 at time 1.0
  thread 1 at time 0.5
  thread 0 at time 1.5
  thread 0 at time 2.0
  thread 1 at time 1.0
  thread 2 at time 0.5
  thread 0 at time 2.5
  thread 1 at time 1.5
  thread 2 at time 1.0thread 1 at time 2.0
  
  thread 0 at time 3.0
  end
  </code></pre>