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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

幫我看看這個(gè)python 是為什么

幫我看看這個(gè)python 是為什么

jeck貓 2018-07-17 08:11:06
#coding=utf-8#!/usr/bin/pythonimport threadimport time# 為線程定義一個(gè)函數(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)建兩個(gè)線程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)驗(yàn) 獲得超4個(gè)贊

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

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


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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