⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hello.c

📁 Pthread lib库完整说明文档
💻 C
字号:
/******************************************************************************* FILE: hello.c* DESCRIPTION:*   A "hello world" Pthreads program.  Demonstrates thread creation and*   termination.* AUTHOR: Blaise Barney* LAST REVISED: 04/05/05******************************************************************************/#include <pthread.h>#include <stdio.h>#include <stdlib.h>#define NUM_THREADS	5void *PrintHello(void *threadid){   printf("\n%d: Hello World!\n", threadid);   pthread_exit(NULL);}int main(int argc, char *argv[]){pthread_t threads[NUM_THREADS];int rc, t;for(t=0;t<NUM_THREADS;t++){  printf("Creating thread %d\n", t);  rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);  if (rc){    printf("ERROR; return code from pthread_create() is %d\n", rc);    exit(-1);    }  }pthread_exit(NULL);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -