2013年12月18日

linux C 多线程/线程池编程 同步实例

摘要: 在多线程、线程池编程中经常会遇到同步的问题。1.创建线程 函数原型:int pthread_create(pthread_t *thread, const pthread_attr_t *attr,void*(*start_routine) (void *), void *arg); 参数:thread指向线程id的指针;attr指向线程属性的指针;第三个为执行的方法的函数指针;arg指向给方法传递的参数的指针。2.互斥变量 (1)互斥变量 pthread_mutex_t (2)互斥变量锁定 int pthread_mutex_lock(pthread_mutex_t *mutex... 阅读全文

posted @ 2013-12-18 19:22 旭东的博客 阅读(2686) 评论(0) 推荐(1) 编辑

C语言数字与字符串转换 atoi()函数、itoa()函数、sprintf()函数

摘要: 在编程中经常需要用到数字与字符串的转换,下面就总结一下。1.atoi() C/C++标准库函数,用于字符串到整数的转换。 函数原型:int atoi (const char * str);1 #include 2 #include 3 int main ()4 {5 char *numchars="1234";6 int num=atoi(numchars);7 printf("%d\n",num);8 return 0;9 } 另外C/C++还提供的标准库函数有: (1)long int atol ( const char * str ); (2... 阅读全文

posted @ 2013-12-18 11:14 旭东的博客 阅读(11938) 评论(0) 推荐(0) 编辑

导航