Common functions:
1. Create a thread with the Pthread_create () function. If 0 is returned successfully.
int Pthread_create (pthread_t *thread, const pthread_attr_t *attr, void * (Start_routine) (void*), void * ARG);
2. Exit Mode:
A. Return returns
B. exit () function, function prototype void exit (int status);
C. pthread_exit function, function prototype void pthread_exit (void * retval);
Note: When you exit using mode B, the entire process will end.
3. Use the Pthread_join () function to connect.
The function function is used to wait for the end of a thread of threads before executing the subsequent content.
Pthread_join (pthread_t thread, void** threadreturn);
Example: pthread_t tid1;
void *join_param;
Pthread_create (&TID1, NULL, PTHREAD_FUNC, NULL); Open a new thread tid1, and run Pthread_func ();
Pthread_join (PID1, &join_param); This connection function was called.
After that, you will wait for the TID1 thread to finish executing before executing the following
printf ("Hello \ n");
......
Multi-thread Linux programming (1)--common functions