操作系统:Ubuntu 11.04 \n \l
In below Programpthread
正在创建新线程,但在注册时失败。
#include<pthread.h>
#include <pjlib.h>
#include <pjlib-util.h>
void serila_port_handler(void);
int main()
{
pthread_t trd_hndler;
if(pthread_create(&trd_hndler,NULL,serila_port_handler,NULL))
{
printf("ERROR while initializing serial port_thread \n");
}
pthread_join(trd_hndler,NULL);
}
void serila_port_handler(void)
{
int ret,rc;
pj_thread_desc ptd;
pj_thread_t *thread =0;
bzero(&ptd, sizeof(pj_thread_desc));
if ( (rc = pj_thread_register("serialportthread",ptd, &thread)) != PJ_SUCCESS) {
printf("Error in pj_thread_register Return Val.: %d\n",rc);
exit(1);
}
printf("pj_thread_register Success!");
sleep(10);
}
输出:
Error in pj_thread_register Return Val.: 120022