第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

幫我看看這個python 是為什么

幫我看看這個python 是為什么

jeck貓 2018-07-17 08:11:06
#coding=utf-8#!/usr/bin/pythonimport threadimport time# 為線程定義一個函數(shù)def print_time( threadName, delay):   count = 0   while count < 5:      time.sleep(delay)      count += 1      print "%s: %s" % ( threadName, time.ctime(time.time()) )# 創(chuàng)建兩個線程try:   thread.start_new_thread( print_time, ("Thread-1", 2, ) )   thread.start_new_thread( print_time, ("Thread-2", 4, ) )except:   print "Error: unable to start thread"while 1:   pass為毛去掉while 1:        pass線程定義的函數(shù) print_time 就不執(zhí)行了呢
查看完整描述

1 回答

?
HUH函數(shù)

TA貢獻(xiàn)1836條經(jīng)驗 獲得超4個贊

因為創(chuàng)建的線程是主進(jìn)程的子線程啊,吧while無限循環(huán)去掉了,主進(jìn)程一建立子線程就立刻結(jié)束,那么子線程也會立刻被銷毀。

可以了解下線程的生命吧~


查看完整回答
反對 回復(fù) 2018-07-18
  • 1 回答
  • 0 關(guān)注
  • 377 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號