#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
static pthread_t g_sttest_pthread;
static int running = 1;
static void *test_thread(void *p)
{
int status = 0;
while (running)
{
usleep(1000);
printf("%s[%d] test_thread \n",__func__,__LINE__);
}
printf("%s[%d] test_thread \n",__func__,__LINE__);
return NULL;
}
int main()
{
pthread_create(&g_sttest_pthread, 0, test_thread, NULL);
while( 'q' != getchar() )
{
usleep(100000);
}
running = 0;
pthread_join(g_sttest_pthread, NULL);
return 0;
}
gcc pthread_test.c -o pthread_test -lpthread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread
test_thread[18] test_thread