import threading from time import ctime,sleep import random
def order(threadName,aaa): global orderSuccess print("----order-----------" + threadName) print(aaa) sleep(2) randomP = random.randint(0,100) print(randomP) if randomP>50: orderSuccess = True orderSuccess=False
t1 = threading.Thread(target=order,args=(u'1111','aaa')) t1.start()
t2 = threading.Thread(target=order,args=(u'2222','bbb')) t2.start()
t1.join() t2.join() print(orderSuccess)
|