Jjunxi
10/26/2017 - 12:25 PM

multi-thread

multi-thread

import time
import threading

NUM_THREADS = 5

class MyThread(threading.Thread):
    name = None
    
    def __init__(self, name):
        super(MyThread, self).__init__()
        
    def run(self):
        while True:
          # do thread job here
          time.sleep(0.1)
          pass

threads = [MyThread() for i in range(NUM_THREAD)]

for t in threads:
        t.setDaemon(False)
        t.start()
        
for t in threads:
        t.join()