📄 test1.cpp
字号:
#include <pthread.h>#include <iostream.h>#include <stdlib.h>void* thread_1(void *p){ while (1) { cout<<"1"<<endl; usleep(300000); } return NULL;}void* thread_2(void *p){ while (1) { cout<<"2"<<endl; usleep(300000); } return NULL;}int main(int argc,char **argv){ pthread_t ntid_send, ntid_rcv; int Err; Err=pthread_create(&ntid_send,NULL,thread_1, NULL); if(Err!=0) printf("Create thread failed,thread index: ntid_send \n"); Err=pthread_create(&ntid_rcv,NULL,thread_2, NULL); if(Err!=0) printf("Create thread failed,thread index: ntid_rcv.\n"); int err1=pthread_join(ntid_send,NULL); int err2=pthread_join(ntid_rcv,NULL); if(err1!=0 || err2!=0) { printf("The child thread: %d %d.\r\n",err1,err2); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -