---
title: HTL_thread_getspecific
description: "获取线程私有变量的值。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2300/accel/kunpengaccel_ksl_16_0099.html
sourcePath: /source/zh/kunpengboostkithistory/2300/accel/kunpengaccel_ksl_16_0099.html
indexId: 880ea45983b122db4fb2fe343ae309f85d41c5a3e17805f814a59e8ad422cec974
---
# HTL_thread_getspecific

获取线程私有变量的值。

#### 接口定义

void *HTL_thread_getspecific(HTL_thread_key_t thread_key);


#### 描述

HTL_thread_getspecific()用于在线程中获取线程私有变量thread_key的值，通过返回值返回线程私有变量值value，若调用者从未设置线程私有变量的值，该函数将会返回值NULL。


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| thread\_key | HTL\_thread\_key\_t | 线程私有变量句柄。 | 输入 |


#### 返回值

线程私有变量的值。


#### 示例

```
int *tmp = (int*)HTL_thread_getspecific(tls);
```
