线程和进程的区别及Python代码实例
答案:1 悬赏:0
解决时间 2021-03-15 13:56
- 提问者网友:冷场帝
- 2021-03-14 20:39
线程和进程的区别及Python代码实例
最佳答案
- 二级知识专家网友:一个很哇塞的汉子
- 2021-03-14 21:20
python的脚本让一个进程中运行两个线程:
import time
import thread
def Ordering(interval):
cnt = 0
while cnt<100:
print '好了,你订餐成功,订餐号码是:%d号 订餐时间是:%s 请在旁边耐心等待\n\n'%(cnt, time.ctime())
time.sleep(interval)
cnt+=1
thread.exit_thread()
def Notice(interval):
cnt = 0
while cnt<100:
print '谁的号码是%d,您的餐好了,过来取一下62616964757a686964616fe78988e69d8331333361313330\n'%(cnt)
time.sleep(interval)
cnt+=1
thread.exit_thread()
def work(): #Use thread.start_new_thread() to create 2 new threads
thread.start_new_thread(Ordering,(1,))
thread.start_new_thread(Notice,(5,))
if __name__=='__main__':
work()
import time
import thread
def Ordering(interval):
cnt = 0
while cnt<100:
print '好了,你订餐成功,订餐号码是:%d号 订餐时间是:%s 请在旁边耐心等待\n\n'%(cnt, time.ctime())
time.sleep(interval)
cnt+=1
thread.exit_thread()
def Notice(interval):
cnt = 0
while cnt<100:
print '谁的号码是%d,您的餐好了,过来取一下62616964757a686964616fe78988e69d8331333361313330\n'%(cnt)
time.sleep(interval)
cnt+=1
thread.exit_thread()
def work(): #Use thread.start_new_thread() to create 2 new threads
thread.start_new_thread(Ordering,(1,))
thread.start_new_thread(Notice,(5,))
if __name__=='__main__':
work()
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |