I would like to know the difference between a thread entry function:
void* thread_function (void* parameter)
{
struct parameter * thread_data = (struct parameter *)parameter;
char buffer[20];
int temp;
printf_buffer(buffer);
}
and a normal function:
void printf_buffer(char *buffer)
{
printf("buffer is %s",buffer);
return;
}
I know a thread entry is called when a thread is created, and how normal functions are used.
Are there any other differences between thread entry functions and a normal functions in terms of execution , behavior, or creating instances?
There is no difference in the language between what you call a “thread function” (although Justin has edited to call it a “thread entry function”) and what you call a “normal function”.
With pthreads, the so-called “start routine” of a thread is a function that takes a single
void*parameter and returnsvoid*, but there’s nothing to stop you calling the same function “normally”.When the start routine of a thread returns, the thread finishes execution, but that’s just because the threading implementation calls it, and then finishes the thread. It’s not because of anything special to do with the start routine itself.