CreateThreadpool function (threadpoolapiset.h)

Allocates a new pool of threads to execute callbacks.

Syntax

PTP_POOL CreateThreadpool(
  PVOID reserved
);

Parameters

reserved

This parameter is reserved and must be NULL.

Return value

If the function succeeds, it returns a pointer to a TP_POOL structure representing the newly allocated thread pool. Applications do not modify the members of this structure.

If function fails, it returns NULL. To retrieve extended error information, call GetLastError.

Remarks

After creating the new thread pool, you should call SetThreadpoolThreadMaximum to specify the maximum number of threads that the pool can allocate and SetThreadpoolThreadMinimum to specify the minimum number of threads available in the pool.

To use the pool, you must associate the pool with a callback environment. To create the callback environment, call InitializeThreadpoolEnvironment. Then, call SetThreadpoolCallbackPool to associate the pool with the callback environment.

To release the thread pool, call CloseThreadpool.

To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or higher.

Examples

For an example, see Using the Thread Pool Functions.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header threadpoolapiset.h (include Windows.h on Windows 7, Windows Server 2008 Windows Server 2008 R2)
Library Kernel32.lib
DLL Kernel32.dll

See also

CloseThreadpool

SetThreadpoolThreadMaximum

SetThreadpoolThreadMinimum

Thread Pools