Skip to content

Instantly share code, notes, and snippets.

@romanoffs
Created December 10, 2019 13:54
Show Gist options
  • Save romanoffs/d0391f651533914bad8dbdd96a9810ec to your computer and use it in GitHub Desktop.
Save romanoffs/d0391f651533914bad8dbdd96a9810ec to your computer and use it in GitHub Desktop.
#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