You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
650 B
Python

2 years ago
import threading
import threading
import time
class MyThread(threading.Thread):
def __init__(self, area):
threading.Thread.__init__(self)
self.area = area
def run(self):
while True:
self.area.writeValues()
time.sleep(1)
def stopThread(thread_name):
for thread in threading.enumerate():
if thread.name == thread_name:
thread.join()
if __name__ == '__main__':
thread1 = MyThread("Thread 1", 1)
thread2 = MyThread("Thread 2", 2)
thread1.start()
thread2.start()
thread1.join()
thread2.join()
print("Exiting main thread")