Skip to content

Instantly share code, notes, and snippets.

@ropo
Created March 1, 2012 13:04
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 ropo/1949701 to your computer and use it in GitHub Desktop.
Save ropo/1949701 to your computer and use it in GitHub Desktop.
volatile
// gcc main.c -O2 -lpthread
#include <pthread.h>
void *threadMain( void *ptr ) {
*(int*)ptr = 0;
}
int main() {
int exitThread = 1; // volatile
pthread_t h;
pthread_create( &h, NULL, threadMain, (void*)&exitThread );
while( exitThread )
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment