使用 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个