水电费
多线程实现
originalNumber=10 def addStepA(varNum): global originalNumber while(varNum>0): originalNumber+=1 time.sleep(1) varNum=varNum-1 print(threading.current_thread().name,"-->:",originalNumber) def addStepB(varNum): global originalNumber while(varNum>0): originalNumber+=1 time.sleep(1) varNum=varNum-1 print(threading.current_thread().name,"-->:",originalNumber) thread_A=threading.Thread(target=addStepA,args=(10,)) thread_B=threading.Thread(target=addStepB,args=(10,)) thread_A.start() thread_B.start() thread_A.join() thread_B.join() print("所有子线程运行结束")