linux下怎么在等待线程结束中设置超时
展开全部
有系统调用:pthread_timedjoin_np
The pthread_timedjoin_np() function performs a join-with-timeout. If thread has not yet terminated, then the call blocks until a maximum time, specified in
abstime. If the timeout expires before thread terminates, the call returns an error. The abstime argument is a structure of the following form, specifying
an absolute time measured since the Epoch (see time(2)):
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
The pthread_timedjoin_np() function performs a join-with-timeout. If thread has not yet terminated, then the call blocks until a maximum time, specified in
abstime. If the timeout expires before thread terminates, the call returns an error. The abstime argument is a structure of the following form, specifying
an absolute time measured since the Epoch (see time(2)):
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询