C++ 设置线程名字
生活随笔
收集整理的這篇文章主要介紹了
C++ 设置线程名字
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用 std::thread
#include <thread> #include <pthread.h>std::thread t(funs, args); pthread_setname_np(t.native_handle(), threadName);通過 pthread_create 創建
#define _GNU_SOURCE #include <pthread.h>pthread_t tid; pthread_create(&tid, NULL, func, NULL); pthread_setname_np(tid, threadName)通過 prctl
prctl(PR_SET_NAME, thdName);注意: 線程名字字符最多16個
總結
以上是生活随笔為你收集整理的C++ 设置线程名字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 多少钱鼻部整形啊?
- 下一篇: 地下城与勇士dnf无尽的永恒有什么用处?