Beginthread
Encyclopedia
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
.
Thread (computer science)
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...
within the current process. It is part of the Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
runtime library
Runtime library
In computer programming, a runtime library is a special program library used by a compiler, to implement functions built into a programming language, during the execution of a computer program...
and is declared
Declaration (computer science)
In programming languages, a declaration specifies the identifier, type, and other aspects of language elements such as variables and functions. It is used to announce the existence of the element to the compiler; this is important in many strongly-typed languages that require variables and their...
in the process.h
Process.h
process.h is a 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 library functions in their C library...
header file
Header file
Some programming languages use header files. These files allow programmers to separate certain elements of a program's source code into reusable files. Header files commonly contain forward declarations of classes, subroutines, variables, and other identifiers...
.
Prototype
unsigned long _beginthread(void(* Func)(void*), unsigned Stack_size, void *Arg);
Func
Thread execution starts at the beginning of the functionfunc
. 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 bystack_size
. If the value of stack_size
is zero, the operating system creates a stack the same size as that of the main thread.Arg
The operating system passes Arg to Func when execution begins.Arg
can be any 32-bit value cast to void*.