---
title: HTL_thread_cond_init
description: "初始化条件变量。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2300/accel/kunpengaccel_ksl_16_0124.html
sourcePath: /source/zh/kunpengboostkithistory/2300/accel/kunpengaccel_ksl_16_0124.html
indexId: cbda159e29e1c74ac385129a91be6b6ecf02b49aa272d1f97e293cec03c6249074
---
# HTL_thread_cond_init

初始化条件变量。

#### 接口定义

int HTL_thread_cond_init(HTL_thread_cond_t *thread_cond, const HTL_thread_condattr_t *thread_condattr);


#### 描述

HTL_thread_cond_init()根据条件属性thread_condattr初始化条件变量，并通过thread_cond返回其句柄。

条件变量thread_cond使用完后需通过函数HTL_thread_cond_destroy()销毁。

该函数仅支持条件变量属性thread_condattr设置为NULL。


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| thread\_cond | HTL\_thread\_cond\_t \* | 条件变量句柄地址。 | 输出 |
| thread\_condattr | HTL\_thread\_condattr\_t \* | 条件变量属性句柄地址。 | 输入 |


#### 返回值

- HTL_THREAD_SUCCESS：成功。
- 其他：失败。见错误码定义。


#### 示例

```
HTL_thread_cond_t cond = HTL_THREAD_COND_NULL;
ret = HTL_thread_cond_init(&cond, NULL);
```
