C++ 多线程实现 最近码代码用到了多线程,总结一下相关用法,可能不是很全面,只是用到的一些基础。 1. 简单的多线程实现 #include <iostream> #include <pthread.h> ... void* function(void) { cout<<"hello world"<<endl; return 0; } int main() { ... int thread_num = 5; pthread_t td[thread_num]; for(int i = 0;i<thread_num;i++) { int ret = pthread_create(