在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ python:線程與進(jìn)程

python:線程與進(jìn)程

# thread.py

import os

print(os.getpid())

def dead_loop():
    while True:
        pass
    
dead_loop()

保存為 thread.py

$ python3 thread.py
2617
$ cat /proc/2617/status
Name:    python3
Umask:    0022
State:    R (running)
Tgid:    2617
Ngid:    0
Pid:    2617
PPid:    2274
TracerPid:    0
Uid:    1000    1000    1000    1000
Gid:    1000    1000    1000    1000
FDSize:    256
Groups:    24 25 29 30 44 46 108 114 115 119 136 1000 
NStgid:    2617
NSpid:    2617
NSpgid:    2617
NSsid:    2274
Threads:    1

Threads: 1 表示有一個線程,請問,這個線程的線程號是多少?

回答
編輯回答
北城荒

Pid 這個是進(jìn)程的ID,更準(zhǔn)確的說應(yīng)該是線程的ID
/proc/pid/status中的Pid就是ps命令的LWP列輸出,PID一列其實是進(jìn)程組,而LWP是輕量級進(jìn)程,也就是線程,因為所有的進(jìn)程必須一個線程,那就是它自己
參考自http://blog.csdn.net/zjl41009...

2017年1月30日 16:46
編輯回答
兮顏
2018年9月19日 02:16