程序如下: #include "apue.h" #include <pthread.h> pthread_t ntid; void printids(const char *s) { pid_t pid; pthread_t tid; pid = getpid(); tid = pthread_self(); printf("%s pid %u tid %u (0x%x)\n", s, (unsigned int)pid, (unsigned int)tid, (unsigned int)tid); } void * thr_fn(void *arg) { printids("new thread: "); return((void *)0); } int main(void) { int err; err = pthread_create...
by zxbjlu1983 - 程序开发 - 2006-08-21 11:14:37 阅读(4967) 回复(5)
/tmp/ccJl8mqQ.o(.text+0x497): In function `main': : undefined reference to `pthread_create' 我在函数里创建了线程,也有#include <pthread.h> 不知道为何抱这个错,请问怎样解决。谢谢大家了
主线程pthread_create创建一堆线程序,正常执行,收到reset命令后,执行pthread_cancel停止开始启动的线程,重新读参数,再次pthread_create,但是这次pthread_create函数就block在那里了. 请高人指教. 是否跟thead tls有关系.
int main()
{
int pcount=10;
unsigned char *kk = "1312312039423095sdlk#*&^$", oo[60];
int len_s, *len_d, i, ret;
for(i=0; i
为什么这个程序编译不了? 完全和书上一样啊?pthread_create 有什么问题吗? 编译结果: [wanglt@sz-gw multi]$ make hello_multi cc hello_multi.c -o hello_multi /tmp/ccNeEOUL.o: In function `main': /tmp/ccNeEOUL.o(.text+0x17): undefined reference to `pthread_create' /tmp/ccNeEOUL.o(.text+0x2f): undefined reference to `pthread_create' /tmp/ccNeEOUL.o(.text+0x3f): undefined reference to `pthread_jo...
设置 signal(SIGCHLD,ChildThreadQuitSignal); 然后用 pthread_create()创建新线程 当 新创建的线程退出时主线程没有执行ChildThreadQuitSignal(), 是否用pthread_create创建的新线程父线程不是创建它的线程,好像用fork就可以的,能有什么办法让pthread_create创建出来的线程在退出时通知主线程呢,求各位老大帮忙,在线等
请教一下各位高手
我的程序在redhat上运行是可以的,但是弄到AS3重新编译后在出现pthread_create时段错误。
下面是我写的一个小测试程序,也有同样的问题
#include <pthread.h>
#include
设置 signal(SIGCHLD,ChildThreadQuitSignal); 然后用 pthread_create()创建新线程 当 新创建的线程退出时主线程没有执行ChildThreadQuitSignal(), 是否用pthread_create创建的新线程父线程不是创建它的线程,好像用fork就可以的,能有什么办法让pthread_create创建出来的线程在退出时通知主线程呢,求各位老大帮忙,在线等
[code]代码如下 void * MainLoop(void *) { cout << "run in thread " << endl; sleep(10); return NULL; } int main(int argc,char **argv) { pthread_t thread; int ret = pthread_create(&thread,NULL,MainLoop,NULL); if(ret != 0) cout << "create failed " << endl; getchar(); return 0; } [/code] //代码大致是这样...
比如有个函数原形 void* myfunc(void* param); 要求写一个函数 RunThreads,可以创建(pthread_create)线程myfunc,大致为: void RunThreads(...Func) { ...... pthread_create(, NULL,...Func,NULL); ...... } 调用方式: RunThreads(...myfunc);//启动线程