Begin & End Thread Functions in Windows

Started by Kalyan, Jul 29, 2008, 10:27 AM

Previous topic - Next topic

Kalyan

Begin & End Thread Functions in Windows

The _beginthread and _beginthreadex Functions

The _beginthread and _beginthreadex functions create a new thread. A thread shares the code and data segments of a process with other threads in the process but has its own unique register values, stack space, and current instruction address. The system gives CPU time to each thread, so that all threads in a process can execute concurrently.

_beginthread and _beginthreadex are similar to the CreateThread function in the Win32 API but has these differences:

· _beginthread and _beginthreadex let you pass multiple arguments to the thread.

· They initialize certain C run-time library variables. This is important only if you use the C run-time library in your threads.

· CreateThread helps provide control over security attributes. You can use this function to start a thread in a suspended state.

_beginthread and _beginthreadex return a handle to the new thread if successful or an error code if there was an error.

The _endthread and _endthreadex Functions

The _endthread function terminates a thread created by _beginthread (and similarly, _endthreadex terminates a thread created by _beginthreadex). Threads terminate automatically when they finish. _endthread and _endthreadex are useful for conditional termination from within a thread. A thread dedicated to communications processing, for example, can quit if it is unable to get control of the communications port.

jeanstorm

I have read the Begin & End Thread Functions in Windows, and Begin & End Thread Functions in Windows  is very great. I am really happy after reading Begin & End Thread Functions in Windows.

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview