#include #include #include #include long long int i = 0; static void bye (void) { printf ("Goodbye.\n"); } void *thread_severity() { while (1) { atexit(bye); i++; if ( i >= 1000000) { printf("i is enough.\n"); return NULL; } } return NULL; } int main (void) { pthread_t thread_severity_id, thread_fmtmsg_id; pthread_create(&thread_fmtmsg_id, NULL, thread_severity, NULL); while(1) { if (i >= 500000) exit(0); usleep(1000); } }