C#多线程函数如何传参数
发布网友
发布时间:2022-04-27 08:25
我来回答
共1个回答
热心网友
时间:2022-06-29 04:39
你那个方法我没怎么用过 这个是我写的一个程序中线程的创建
struct myarg{
U32 *fd;
U32 *fd_id;
U32 *qsend_msgid,*qrecv_msgid;
struct my_msg_st *qsend_data;
struct my_msg_st *qrecv_data;
};
main()
{
pthread_t tidp_init,tidp_read,tidp_write;
my_arg.fd = fd;
my_arg.qrecv_msgid = &recv_msgid;
my_arg.qsend_msgid = &send_msgid;
if(pthread_create(&tidp_init,NULL,thread_fun_date,&my_arg) != 0)
{
printf("thread_fun_init is over !\n");
}
if(pthread_create(&tidp_read,NULL,thread_fun_read,&my_arg) != 0)
{
printf("thread_fun_read is over !\n");
}
if(pthread_create(&tidp_write,NULL,thread_fun_write,&my_arg) != 0)
{
printf("thread_fun_write is over !\n");
}
}
void*thread_fun_read(void * my_arg)
{
printf("!!!!!!! thread_fun_read !!!!!!!!!!!!\n");
U32 i;
pthread_t tidp;
struct myarg *p_my_arg,fd_myarg[UART_NUM];
p_my_arg = (struct myarg *)my_arg;
}