Here is my code, but the output on screen is not what I expected.
import threading
import time
def foo_1():
for i in range(10):
print ("foo_1: ")
time.sleep(0.2)
def foo_2():
for i in range(10):
print("foo_2: ")
time.sleep(0.2)
t1=threading.Thread(target=foo_1)
t2=threading.Thread(target=foo_2)
t1.start()
t2.start()
Here is output, clearly some print function didn't print '\n' before sleep. I don't know why :(
foo_1:
foo_2:
foo_2: foo_1:
foo_1: foo_2:
foo_1: foo_2:
foo_2:
foo_1:
foo_2:
foo_1:
foo_2:
foo_1:
foo_2:
foo_1:
foo_2:
foo_1:
foo_2:
foo_1: