设为首页 加入收藏

TOP

Python多线程之线程创建和终止(二)
2015-02-02 14:37:55 来源: 作者: 【 】 浏览:22
Tags:Python 线程 建和 终止
g.currentThread())+'stoped\n'?
? ? print 'after A stoped, '+FileA.name + ' closed? '+repr(FileA.closed)+'\n'?
? ? if not FileA.closed:?
? ? ? ? print 'You see the differents, the resource in subthread may not released with setDaemon()'?
? ? ? ? FileA.close()?
if __name__ =='__main__':?
? ? print '-------stop subthread example with Event:----------\n'?
? ? evtstop()?
? ? print '-------Daemon stop subthread example :----------\n'?
? ? daemonstop()?


运行结果是:


-------stop subthread example with Event:----------?
<_MainThread(MainThread, started 2436)>alive?
testA.txt closed? False?
testB.txt closed? False?
subthreadA alive?
subthreadB alive?
?
<_MainThread(MainThread, started 2436)>send stop signal?
close opened file in subthreadA?
close opened file in subthreadB?
?
subthreadA stoped?
subthreadB stoped?
?
<_MainThread(MainThread, started 2436)>stoped?
after A stoped, testA.txt closed? True?
after A stoped, testB.txt closed? True?
-------Daemon stop subthread example :----------?
<_MainThread(MainThread, started 2436)>alive?
testA.txt closed? False?
subthreadA alive?
subthreadA stoped?
<_MainThread(MainThread, started 2436)>stoped?
after A stoped, testA.txt closed? False?
You see the differents, the resource in subthread may not released with setDaemon()?


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Python实现支持JSON存储和解析的.. 下一篇Android开发实践:编译VLC For An..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: