function BeginThread(SecurityAttributes: Pointer; StackSize: LongWord; ThreadFunc: TThreadFunc; Parameter: Pointer; CreationFlags: LongWord; var ThreadId: TThreadID): Integer;
extern PACKAGE int __fastcall BeginThread(void * SecurityAttributes, unsigned StackSize, TThreadFunc ThreadFunc, void * Parameter, unsigned CreationFlags, unsigned &ThreadId);
Spawns a separate thread of execution.
Use this routine or a TThread object to spawn separate threads of execution. BeginThread spawns a new thread of execution and sets the global IsMultiThread variable, thereby making the heap thread-safe.
ThreadFunc is the thread function. This is the code that executes in the new thread of execution. ThreadFunc should handle all of its own exceptions. However, because BeginThread sets up an execution frame, the system's default exception handler will catch any exceptions that escape ThreadFunc.
Parameter points to a single 32-bit parameter that is passed, uninterpreted, to ThreadFunc.
ThreadId returns the unique identifier for the new thread. This ID appears in the Thread Status box of the debugger.
SecurityAttributes is a pointer to a Windows SecurityAttributes record (structure). For details on security attributes, see the Microsoft documentation.
StackSize is the size of the stack reserved for the new thread when
CreationFlags includes STACK_SIZE_IS_A_RESERVATION. Otherwise, this parameter is ignored.
CreationFlags is a set of bits or'ed together that are drawn from the following:
The thread is created in a suspended state and does not run until the Windows API ResumeThread function is called. If this flag is not included, the new thread starts running as soon as it is created.
BeginThread returns the Windows thread handle. A return value of 0 indicates failure.
Attribute is a structure containing information about the thread such as its priority, its schedule policy, and its stack size.