1樓:Elvin Peng
name 是當前執行緒的屬性, getName 是當前執行緒的方法。
儘管threading.current_thread().name 和 threading.
current_thread().getName() 的結果一樣,但是完全不是同一種東西呀, 例如通過 threading.current_thread().
name = 'thread_python' 來改變它。
用法說明:
# -*- coding: utf8 -*-import
threading
defthead_hello
'thread is running ...'
.format
(name
=threading
.current_thread().
name
)threading
.current_thread().
name
='python'
'thread is running ...'
.format
(name
=threading
.current_thread().
getName
'thread ended'
.format
(name
=threading
.current_thread().
name)if
__name__
=='__main__':t
=threading
.Thread
(target
=thead_hello
,name
='Hello')t
.start
()# 輸出為:
# thread Hello is running ...
# thread python is running ...
# thread python ended原理說明:# -*- coding: utf8 -*-class
A():
def__init__
(self
):self
.name
='hello'
defget_name
(self
):return
self
.name
if__name__
=='__main__':a
=A()printa.
name
printa.
get_name()
沈曉海為何不溫不火?
嗜肉乳酸桿菌 首先,我覺得用 火不火 評價乙個演員未免有點狹隘,當然的確是乙個方面。90後小時候的男神好像現在大多不太火了,這很正常啊,但他們有自己輝煌的時代,我不願意稱之為 生不逢時 現在大環境太浮躁了,很多時候不需要有過硬的實力只要有話題度就有市場,所以才總有 火不火 的問題出現。當話題褪去之後...
方證 和 沖虛 為何不像政治人物?
唐大 政治生態很複雜,但是從旁觀者的角度,再結合 笑傲江湖 的創作背景,大致是可以分為三種人的 當權派 造反派 逍遙派。方證和沖虛,無疑就是當權派了,而且是整體正教人士的當權派,與之相對應的,左冷禪就是造反派。而站在五岳劍派的角度上,左又成了當權派,岳不群則是造反派。至於正教人士的對立面日月神教,起...
小公尺為何不進軍美國和歐洲市場
球哥 海外市場尤其是歐美高階市場需要多年的積累和布局,華為退出美國市場,中興在歐洲沒有利潤,中國產品牌尤其是像小公尺這種類似暴發戶的手機廠商,還要交很多學費 Jhona 專利費。畢竟是近年興起的品牌,較聯想華為什麼的專利還是太少了,並且歐美對這方面有特別看重。同時對谷歌的支援也是乙個大問題 行不更名...