1. 程式人生 > >Linux 執行緒 ID 和 設定名字

Linux 執行緒 ID 和 設定名字

標頭檔案要有:

#include <unistd.h>
#include <pthread.h>
#include <sys/syscall.h>
#include <sys/prctl.h>

程式:

    printf(" tid : %d \n", syscall(224));
    prctl(PR_SET_NAME, "test_Thread");

 

執行後

 ps 結果:

當 不是多線,則 pid = tid ;