[#BloombergLP-bslmt-ThreadUtil-createKey]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslmt.adoc[bslmt]::xref:BloombergLP/bslmt/ThreadUtil.adoc[ThreadUtil]::createKey
:relfileprefix: ../../../
:mrdocs:

Load into the specified `key` a new process&hyphen;wide identifier that can be used to store (via `setSpecific`) and retrieve (via `getSpecific`) a pointer value local to each thread, and associate with the new key the specified `threadKeyCleanupFunction`, which will be called by each thread, if `threadKeyCleanupFunction` is non&hyphen;zero and the value associated with `key` for that thread is non&hyphen;zero, with the associated value as an argument, after the function passed to `create` has returned and before the thread terminates&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; Note that multiple keys can be defined, which can result in multiple thread key cleanup functions being called for a given thread&period;

== Synopsis

Declared in `&lt;bslmt&lowbar;threadutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
createKey(
    xref:BloombergLP/bslmt/ThreadUtil/Key.adoc[Key]* key,
    xref:BloombergLP/bslmt/ThreadUtil/Destructor.adoc[Destructor] threadKeyCleanupFunction);
----


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