1.需要安装对应的库 sudo apt-get install -y glibc-doc manpages-posix-dev
2.编译时需要 使用-lpthread. 命令: sudo gcc a.c -o a -lpthread
3.程序
#include <pthread.h>
// 创建线程
pthread_t timer_thread, main_thread;
// 创建定时器线程
pthread_create(&timer_thread, NULL, timer_func, NULL);
// 创建主函数线程
pthread_create(&main_thread, NULL, main_func, NULL);