Skip to content

Instantly share code, notes, and snippets.

@khoa-io
Last active September 25, 2022 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khoa-io/e0b388ccfcc6f5b450ebbc4a791c2cdc to your computer and use it in GitHub Desktop.
Save khoa-io/e0b388ccfcc6f5b450ebbc4a791c2cdc to your computer and use it in GitHub Desktop.
Hello Multithreading World (Pthreads)
#include <pthread.h>
#include <stdio.h>
void *helloWorld(void *arg) {
(void)(arg);
printf("Hello Multithreading World\n");
return (void *)0;
}
int main() {
pthread_t myThread;
int exitCode = 0;
exitCode = pthread_create(&myThread, NULL, &helloWorld, NULL);
if (exitCode != 0) {
return exitCode;
}
exitCode = pthread_join(myThread, NULL);
if (exitCode != 0) {
return exitCode;
}
return exitCode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment