早教吧 育儿知识 作业答案 考试题库 百科 知识分享

c语言指针数组问题uthreadt*t1,*t2,*t3,*t4t1=uthreac语言指针数组问题uthreadt*t1,*t2,*t3,*t4t1=uthreadcreate(person,*p);t2=uthreadcreate(person,*p);t3=uthreadcreate(person,*p);t4=uthreadcreate(person,*p);t5=uthreadcrea

题目详情
c 语言指针数组问题uthread_t *t1,*t2,*t3,*t4 t1 =uthrea
c 语言指针数组问题uthread_t *t1,*t2,*t3,*t4 t1 =uthread_create(person,*p);
t2 =uthread_create(person,*p);
t3 =uthread_create(person,*p);
t4 =uthread_create(person,*p);
t5 =uthread_create(person,*p);
uthread_join(t1); uthread_join(t2); uthread_join(t3); uthread_join(t3);
我这里想用一个for 循环和数组来代替上面的.也就是说:引用一个新变量n.然后用for 循环产生n个uthread,这些thread在一个数组里.然后在join起来
▼优质解答
答案和解析
//uthread函数是unix里的吧?用法我不太熟悉,但是单纯弄成指针数组还是很简单的.
//我类比于malloc了,写下来有小瑕疵的话你自己根据uthread的用法改一下:
#define n 5

uthread_t *t[n];
int i;
for (i=0;ifor (i=0;i