Skip to content

Instantly share code, notes, and snippets.

@brendanashworth
Created July 17, 2014 22:24
Show Gist options
  • Save brendanashworth/287cebb2edd385d88c63 to your computer and use it in GitHub Desktop.
Save brendanashworth/287cebb2edd385d88c63 to your computer and use it in GitHub Desktop.
Basic example multithreading in C
#import <stdio.h>
#import <pthread.h>
void *threadFunction(void *arg) {
// To be executed when called...
}
int main(void) {
pthread_t *thread;
// Start and launch the thread
pthread_create(&thread, NULL, threadFunction);
// Wait for it to finish
pthread_join(thread, NULL);
// Synchronized, thread finished.
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment