[#BloombergLP-bslmt-ThreadUtilImpl-04-createKey]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::xref:BloombergLP/bslmt/ThreadUtilImpl-04.adoc[ThreadUtilImpl&lt;Platform::PosixThreads&gt;]::createKey
:relfileprefix: ../../../
:mrdocs:

Create a process&hyphen;wide key for thread&hyphen;local storage&period;

== Synopsis

Declared in `&lt;bslmt&lowbar;threadutilimpl&lowbar;pthread&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
createKey(
    xref:BloombergLP/bslmt/ThreadUtilImpl-04/Key.adoc[Key]* key,
    xref:BloombergLP/bslmt_KeyDestructorFunction.adoc[bslmt&lowbar;KeyDestructorFunction] destructor);
----

== Description

Load, into the specified `key`, an identifier that can be used to store (`setSpecific`) and retrieve (`getSpecific`) a single thread&hyphen;specific pointer value&period; Associate with the identifier, the specified `destructor` if a non&hyphen;zero value is specified&period; Return 0 on success, and a non&hyphen;zero value otherwise&period;

== Return Value

0 on success, and a non&hyphen;zero value otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *key*
| receives the new process&hyphen;wide thread&hyphen;local key
| *destructor*
| optional destructor for key values
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
