import _thread
import time
def print_time(threadName, delay, iterations):
start = int(time.time())
for i in range(,iterations):
time.sleep(delay)
seconds_elapsed = str(int(time.time()) - start)
print (threadName if threadName else seconds_elapsed)
try:
_thread.start_new_thread(print_time, (None, , ))
_thread.start_new_thread(print_time, ("Fizz", , ))
_thread.start_new_thread(print_time, ("Buzz", , ))
except:
print ("Error: unable to start thread")
while :
pass
demo2
import _thread
import time
def print_time(threadName, delay, iterations):
start = int(time.time())
for i in range(,iterations):
time.sleep(delay)
seconds_elapsed = str(int(time.time()) - start)
print (threadName if threadName else seconds_elapsed)
try:
_thread.start_new_thread(print_time, (None, , ))
_thread.start_new_thread(print_time, ("Fizz", , ))
_thread.start_new_thread(print_time, ("Buzz", , ))
except:
print ("Error: unable to start thread")
print("complete!")
手机扫一扫
移动阅读更方便
你可能感兴趣的文章