I wrote the following simple code:
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
void* printThreadFunction()
{
puts("***got here*****");
}
int main (int argc, char *argv[])
{
pthread_t printThread;
if (pthread_create(&printThread, NULL, printThreadFunction, NULL) != 0) {
perror("pthread_create");
exit(1);
}
pthread_join(printThread, NULL);
}
This code prints ***got here*****
as I expect. However, if I change printThreadFunction()
to be:
void* printThreadFunction()
{
puts("***got here*****");
while(1); // change here
}
So the code enters an infinite loop, but no printing is being done to the screen- why is that?