Skip to content

Instantly share code, notes, and snippets.

@zodiac1111
Forked from brendanashworth/main.c
Last active August 29, 2015 14:05
Show Gist options
  • Save zodiac1111/4f9f5deec7e513ff0044 to your computer and use it in GitHub Desktop.
Save zodiac1111/4f9f5deec7e513ff0044 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;
}
/// #import is a deprecated GCC extension [-Wdeprecated]
@zodiac1111
Copy link
Author

#import is a deprecated GCC extension [-Wdeprecated]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment