Create a thread with the specified attributes and entry‐point function.

Synopsis

Declared in <bslmt_threadutilimpl_pthread.h>

static
int
create(
    Handle* threadHandle,
    ThreadAttributes const& attributes,
    bslmt_ThreadFunction function,
    void* userData);

Description

Create a new thread of program control having the specified attributes that invokes the specified function with a single argument specified by userData, and load into the specified threadHandle an identifier that may be used to refer to the thread in future calls to this utility. Return 0 on success, and a non‐zero value otherwise. The behavior is undefined if the specified thread is 0 or if attributes.stackSize() has been set to a negative value other than the unset value. Note that unless explicitly "detached" (by detach), or unless the BSLMT_CREATE_DETACHED attribute is specified, a call to join must be made once the thread terminates to reclaim any system resources associated with the newly created identifier.

Return Value

0 on success, and a non‐zero value otherwise

Parameters

Name

Description

threadHandle

receives an identifier for the new thread

attributes

properties for the new thread

function

entry‐point function invoked by the new thread

userData

sole argument passed to function

Created with MrDocs