`

Linux系统GDB调试-2

 
阅读更多

多线程调试示例程序

#include <pthread.h>
#include <stdio.h>

void print_xs(void* a)
{
 while(1)
 {
    sleep(1);
    printf("thread %d,x\n",pthread_self());
 }
 return NULL;
}

void print_ys(void* a )
{
 while(1)
 {
    sleep(1);
    printf("thread %d,y\n",pthread_self());
 }
 return NULL;
}

int main()
{
  pthread_t thread_id1,thread_id2;
  pthread_create(&thread_id1,NULL,&print_xs,NULL);
  pthread_create(&thread_id2,NULL,&print_ys,NULL);
  while(1);
return 0;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics