Advertisement
adnan360

Threading without class.py

Jan 5th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. # http://stackoverflow.com/questions/23100704/running-infinite-loops-using-threads-in-python
  2. from threading import Thread
  3.  
  4. def runA():
  5.     while True:
  6.         print 'A\n'
  7.  
  8. def runB():
  9.     while True:
  10.         print 'B\n'
  11.  
  12. if __name__ == "__main__":
  13.     t1 = Thread(target = runA)
  14.     t2 = Thread(target = runB)
  15.     t1.setDaemon(True)
  16.     t2.setDaemon(True)
  17.     t1.start()
  18.     t2.start()
  19.     while True:
  20.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement