beginthread
   HOME

TheInfoList



OR:

The beginthread function creates a new thread of execution within the current process. It is part of the Microsoft Windows
runtime library In computer programming, a runtime library is a set of low-level routines used by a compiler to invoke some of the behaviors of a runtime environment, by inserting calls to the runtime library into compiled executable binary. The runtime enviro ...
and is declared in the process.h
header file Many programming languages and other computer files have a directive, often called include (sometimes copy or import), that causes the contents of the specified file to be inserted into the original file. These included files are called copybooks ...
.


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 for "error number").International Standard for Programming Language C ( ...
.


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).


References

Process.h Threads (computing)