mypthread.c
来自「Some simple source code to show specific」· C语言 代码 · 共 35 行
C
35 行
/*mypthread.c*/#include <pthread.h>#include <stdlib.h>#include <stdio.h>#include <unistd.h>void *thread_function( void *arg ){ int i; for ( i=0; i<5; i++) { printf("This is a thread!\n"); } return NULL;}int main( void ){ pthread_t mythread; if( pthread_create( &mythread, NULL, thread_function, NULL) ) { printf("error creating thread."); } printf("This is main process!\n"); if ( pthread_join( mythread, NULL) ) { printf("error joining thread."); abort(); } printf("%d\n",pthread_self()); exit(0);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?