Program that determines whether changing the current directory using os.chdir in one thread changes the current directory for a thread that already existed before the call to os.chdir My question is how do I get the value of a live thread?
import threading
import time
import os
class MyThread(threading.Thread):
def __init__(self, *args, **kw):
threading.Thread.__init__(self, *args, **kw)
self.sleeptime = 2
def run(self):
for i in range(self.sleeptime):
for j in range(500000):
k = j*j
print(self.name, "finished pass", i)
print(self.name, "finished after", self.sleeptime, "seconds")
bgthreads = threading.active_count()
threadOne = os.chdir("V:\workspace\Python4_Homework10")
threadTwo = os.chdir("V:\workspace")
threadThree = os.chdir("V:")
tt = [MyThread(threadOne), MyThread(threadTwo), MyThread(threadThree)]
for t in tt:
t.start()
print("Threads started")
while threading.active_count() > bgthreads:
time.sleep(2)
print("tick")