Beginthread

The beginthread function creates a new thread of execution within the current process. It is part of the Microsoft Windows runtime library and is declared in the process.h header file.

Prototype

unsigned long _beginthread(void(* Func)(void*), unsigned Stack_size, void *Arg);

Func

Thread execution starts at the beginning of the function func. To terminate the thread correctly, func must call _endthread or end with "return 0", freeing memory allocated by the run time library to support the thread.

Stack_size

The operating system allocates a stack for the thread containing the number of bytes specified by stack_size. If the value of stack_size is zero, the operating system creates a stack the same size as that of the main thread.[1]

Arg

The operating system passes Arg to Func when execution begins. Arg can be any 32-bit value cast to void*.

Return value

Returns the operating system handle of the newly created thread. If unsuccessful, the function returns -1 and sets errno.

Compiler switches

To compile a program using multiple threads with the Microsoft C/C++ Compiler, you must specify the /MT switch (or /MTd, for debug programs).

gollark: All recent computers have extra computers inside them, which have their own probably-basically-unaudited firmware with access to some critical system component or other.
gollark: Basically, computers don't work and you should run away from them.
gollark: Android WiFi chipsets have all kinds of fun bugs like that which sometimes allow remote code execution and which will probably just never be patched on lots of phones.
gollark: That means sacrificing a bunch of nice things. A Linux phone means sacrificing slightly fewer things.
gollark: If you care, consider the "pinephone", which at least has a hardware switch for its modem.

References

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.