Created
March 1, 2012 13:04
-
-
Save ropo/1949701 to your computer and use it in GitHub Desktop.
volatile
This file contains 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
// 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