pthread_jion

#include <pthread.h>
#include <string.h>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>


#pragma warning (disable:4716)


void * pthread_func_test(void * arg);


int main()
{
	pthread_t thread1,thread2;
	pthread_create(&thread1,NULL,pthread_func_test,"This is the Thread_ONE\n");
	pthread_create(&thread2,NULL,pthread_func_test,"This is the Thread_TWO\n");
	pthread_join( thread1, NULL);
	// 等待thread2线程终止
	pthread_join( thread2, NULL);        //这行不写,会发生什么?或写成pthread_join(pt1,NULL);又会怎么样?
}


void * pthread_func_test(void * arg)
{
	printf("%s",arg);


	pthread_exit( NULL);            //显式声明
}

你可能感兴趣的:(thread,C++)