---
title: HTL_thread_revive
description: "唤醒被终止的线程。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengaccel/system-lib/htl/kunpengaccel_ksl_16_0093.html
sourcePath: /source/zh/kunpengaccel/system-lib/htl/kunpengaccel_ksl_16_0093.html
indexId: dd3a581398134f82e541113703e549a84e5283a5e738eb645e28f972bc9c9acf68
---
# 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 = HTL_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]);
    }
```
