title: selective thread termination from parent thread/program
body: <pre><code>def function(message):
  
    if 'START' in  message:
  
      timer = 10
      #start a thread which sleeps for 'timer' and prints "TIMER EXPIRED"
  
    if 'STOP' in message:
  
      #check if timer is still running, terminate thread if yes (print "TIMER STOPPED")
  
  def main():
  
    function('START')
  
    time.sleep(random_time)
  
    function('STOP')
  </code></pre>
  
  <p>1.please suggest what kind of thread is best for this program, thread.start_new_thread() doesn't seem to have exit() or terminate() from main program.</p>
  
  <p>2.how to make sure timer is still running and then terminate thred</p>
  
  <p>need to work with threads since,Process gives an error saying the new process is not able to use variables from old one, i am actually calling other functions rather than printing 'TIMER EXPIRED' and 'TIMER STOPPED'</p>