读书人

py amp; wxpy 线程启动有关问题

发布时间: 2012-03-06 20:47:55 作者: rapoo

py & wxpy 线程启动问题
想实现 这样 一个 过程:
启动线程A ,等待此线程 完了以后 ,然后再 启动线程B 和 线程C 。 (over)

--test1----------------------------------

Python code
def main:    start  threadA  #启动线程threadA    while threadA is running:          time.sleep(2)    start  threadB  #启动线程threadB    start  threadC  #启动线程threadC


问题:应该是start 线程A之后,主程序在while中循环,同时线程A也在执行。可是根据测试的结果是线程A并没有开始运行,所以主程序 一致 死在 while 循环 ,在threadA中有定义线程结束标志, while接收到此标志后 启动线程threadB 和threadC


--test2----------------------------------
Python code
threadA:    do     sometheing  #执行线程threadA的功能    start  threadB     #启动线程threadB    start  threadC     #启动线程threadCdef main:    start  threadA  #启动线程threadA


问题:是不是线程A中不能启动其他线程,这个 测试 有点 小问题 ,但是 可以 实现我上面 需要的 过程

[解决办法]
多程按序行可以使用join。
[解决办法]
Python code
def main:    start threadA #启动线程threadA     threadA.join()    start threadB #启动线程threadB      start threadC #启动线程threadC 

读书人网 >perl python

热点推荐