Beginthread
   HOME

TheInfoList



OR:

The beginthread function creates a new thread of execution within the current process. It is part of the
Microsoft Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
runtime library A runtime library is a library that provides access to the runtime environment that is available to a computer program tailored to the host platform. A runtime environment implements the execution model as required for a development environme ...
and is declared in the
process.h process.h is the C header file which contains function declarations and macros used in working with threads and processes. Most C compilers that target DOS, Windows 3.1x, Win32, OS/2, Novell NetWare or DOS extenders supply this header and the li ...
header file An include directive instructs a text file processor to replace the directive text with the content of a specified file. The act of including may be logical in nature. The processor may simply process the include file content at the location of ...
.


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.MSDN _beginthread
/ref>


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 errno.h is a header file in the standard library of the C programming language. It defines macros for reporting and retrieving error conditions using the symbol errno (short form for "error number").International Standard for Programming Langu ...
.


Compiler switches

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


References

Process.h Threads (computing)