pthread线程总结和使用
#include <iostream>#include <pthread.h>using namespace std;void * thread_proc(void*){ for(int i = 0; i < 10; ++i){ cout << "123" << endl; sleep(1); } return 0;}int main(){ //1 pthread_t thread_id; thread_id = pthread_self(); // if (pthread_equal(thread_id, pthread_self())){ cout << "Equal!" << endl; }else { cout << "Not queal!" << endl; } //2 pthread_t thread_new; int rc = pthread_create(&thread_new, 0, thread_proc, 0); if (rc != 0){ cout << "pthread_create error!" << endl; return -1; } pthread_join(thread_new, 0); pthread_destory(thread_new); return 0;}