如何確定python線程是否已啓動?有一種方法is_alive()
但同時一個線程在運行,這是真正的和之前。確定線程是否已啓動
1
A
回答
0
4
你可以看看ident字段的線程實例。該Python 2.7 documentation for Threading介紹的ident作爲
這個線程或無的「線程標識符」如果線程沒有 啓動。
1
使用isAlive
(或is_alive
)Thread
類方法。
從源http://hg.python.org/cpython/file/2.7/Lib/threading.py#l995:
# ...
def isAlive(self):
"""Return whether the thread is alive.
This method returns True just before the run() method starts until just
after the run() method terminates. The module function enumerate()
returns a list of all alive threads.
"""
assert self.__initialized, "Thread.__init__() not called"
return self.__started.is_set() and not self.__stopped
# ...
相關問題
- 1. 確定進程是否已重新啓動
- 2. 如何確定進程是否已啓動但尚未退出?
- 3. pthread_create是否啓動線程?
- 4. 如何確定setPersistenceEnabled是否已啓用?
- 5. 錯誤線程已啓動/預定
- 6. 當調用myThread.Start(...)時,我們是否確保該線程已啓動?
- 7. java.lang.IllegalThreadStateException:線程已經啓動
- 8. Apache NMS - 如何確定連接是否已經啓動
- 9. 確定MySQL是否已使用skip-grant-tables啓動
- 10. 確定Rails資源控制器是否已啓用動作
- 11. 確定手機是否已重新啓動
- 12. 確定設備是否已移動
- 13. 如何確定Win32線程是否已終止?
- 14. 確定過程是否已經死亡?
- 15. 確定進程是否已掛起
- 16. 一個線程如何確定另一個線程是否已經崩潰?
- 17. Android:AlertDialog.show()是否啓動新的線程?
- 18. 如何確定前臺應用程序是否是啓動器?
- 19. 如何確定Windows應用程序是否在Windows啓動時自動啓動?
- 20. 如何確定線程是否有鎖?
- 21. 確定線程是否被阻塞
- 22. 確定線程是否正在睡眠
- 23. 確定線程是否退出
- 24. 已啓動還是已綁定服務?
- 25. Qt確定應用程序是否從Qt Creator啓動?
- 26. 確定iOS應用程序是否通過Siri啓動
- 27. 確定應用程序是否從AppleScript啓動
- 28. 確定是否由os在後臺啓動cordova應用程序
- 29. 確定應用程序是否從主屏幕啓動?
- 30. 啓動程序如何確定拖動已結束?
'迴歸自我.__ started.is_set(),而不是自我.__ stopped'應返回false開始前。 '在方法開始之前'從doc str意味着'__started'被設置,但線程還沒有運行(很短的時間,我想) – ndpu