HTL_thread_revive
唤醒被终止的线程。
接口定义
int HTL_thread_revive(HTL_thread_pool_t thread_pool, void* (*thread_func)(void *), void *arg, HTL_thread_t *thread);
描述
HTL_thread_revive()用于唤醒被终止的线程,使用新的执行函数thread_func()及其参数arg恢复线程thread。该函数不会更改thread的属性,恢复的线程会被推送到线程池thread_pool中。
虽然采用HTL_thread指针传递线程句柄参数,但不会更新thread的句柄。其中thread必须是尚未释放的已终止线程。被其他调用阻塞的线程可能无法恢复。
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
thread_pool |
HTL_thread_pool_t * |
池句柄。 |
输入 |
thread_func |
void* (*thread_func)(void *) |
新的ULT执行的函数。 |
输入 |
arg |
void * |
thread_func的入参。 |
输入 |
thread |
HTL_thread_t * |
ULT句柄。 |
输入/输出 |
返回值
- HTL_THREAD_SUCCESS:成功。
- 其他:失败。见错误码定义。
示例
/* Create ULTs */ for (i = 0; i < num_threads; i++) { ret = HLT_thread_create_from_pool(my_pool, &threads[i], NULL, thread_func, (void *)1); } /* Join ULTs */ for (i = 0; i < num_threads; i++) { ret = HTL_thread_join_np(&threads[i]); } /* Revive ULTs with a different function */ for (i = 0; i < num_threads; i++) { ret = HTL_thread_revive(my_pool, thread_func2, (void *)2, &threads[i]); } /* Join and free ULTs */ for (i = 0; i < num_threads; i++) { ret = HTL_thread_free(&threads[i]); }
父主题: 线程函数