Created
December 10, 2019 13:54
-
-
Save romanoffs/d0391f651533914bad8dbdd96a9810ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <pthread.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define NUMBER_OF_THREADS 10 | |
void *print_hello_world(void *tid) { | |
printf("Hello World This Thread is : %d\n", tid); | |
pthread_exit(NULL); | |
} | |
int main() { | |
pthread_t threads[NUMBER_OF_THREADS]; | |
int status, i; | |
for (i = 0; i < NUMBER_OF_THREADS; i++) { | |
printf("Это основная програма. Создание потока: %d\n", i); | |
status = pthread_create(&threads[i], NULL, print_hello_world, (void *) i); | |
if (status != 0) { | |
printf("Жаль функция pthread_create вернула код ошибки %d\n", status); | |
exit(-1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment