Created
July 17, 2014 22:24
-
-
Save brendanashworth/287cebb2edd385d88c63 to your computer and use it in GitHub Desktop.
Basic example multithreading in C
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
#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