#include
#include
void* thrFunc(void *arg);
void main()
{
pthread_t thread;
void *ptr;
int a = 99;
if ( pthread_create( &thread , NULL , thrFunc , (void*)a ) < 0 )
perror( "create" );
if ( pthread_join( thread , &ptr ) < 0 )
perror( "join" );
fprintf( stderr , "main thread , ret %d\n" , *(int*)ptr );
//pthread_exit( ptr );
}
void* thrFunc(void *arg)
{
int ret;
fprintf( stderr , "in Thread, %d\n" , (int)arg );
ret = (int) arg;
pthread_exit( (void*)&ret );
}
1. thrFunc함수내에서
리턴값을 auto변수로 했는데요.