Skip to content

Instantly share code, notes, and snippets.

@krokodilerian
Created June 30, 2016 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krokodilerian/04de4b7ef331623ef3d218fdedf17e46 to your computer and use it in GitHub Desktop.
Save krokodilerian/04de4b7ef331623ef3d218fdedf17e46 to your computer and use it in GitHub Desktop.
volatile int die=0;
void thread_func() {
while (42) {
do_something();
do_anotherthing();
if (die) {
close(fd);
return;
}
}
}
int main() {
pthread_create(thread_func);
pthread_create(thread_func);
pthread_create(thread_func);
wait_for_threads();
}
volatile int die=0;
void thread_func() {
while (42) {
do_something();
do_anotherthing();
if (die) {
close(fd);
return;
}
}
}
int main() {
pthread_create(thread_func);
pthread_create(thread_func);
pthread_create(thread_func);
wait_for_threads();
return die;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment