Skip to content

Instantly share code, notes, and snippets.

@George3d6
Last active December 13, 2018 22:08
Show Gist options
  • Save George3d6/16e9eeaf0331e3fef7c4a7f0460a6f49 to your computer and use it in GitHub Desktop.
Save George3d6/16e9eeaf0331e3fef7c4a7f0460a6f49 to your computer and use it in GitHub Desktop.
#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);
}
@nebkor
Copy link

nebkor commented Dec 13, 2018

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 to void*:

https://gist.github.com/nebkor/34494a3fdd68fd23d959fa72bd219dbe

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