Last active
December 13, 2018 22:08
-
-
Save George3d6/16e9eeaf0331e3fef7c4a7f0460a6f49 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <pthread.h> | |
void *work(void *arg) { /* implementation */ } | |
int main() { | |
pthread_t t1, t2; | |
int magic_nr_1 = 46; | |
int magic_nr_2 = 3; | |
pthread_create(&t1, NULL, thread, (void *) magic_nr_1); | |
pthread_create(&t2, NULL, thread, (void *) magic_nr_2); | |
pthread_join(t1,NULL); | |
pthread_join(t2,NULL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've updated this with a trivial impl that will actually compile and run :) The two most important changes, though, are in 's/thread/work/' for the parameter name in pthread_create, and taking the address of
magic_nr_*
before casting tovoid*
:https://gist.github.com/nebkor/34494a3fdd68fd23d959fa72bd219dbe