网站首页  词典首页

请输入您要查询的函数:

 

术语 exitthread
释义 ExitThread
语法:
C++
VOID WINAPI ExitThread(
__in DWORD dwExitCode
);
ExitThread函数
完调用线程。
参数
dwExitCode [in]
线程的退出代码。
返回值
这个函数没有返回值。
备注
ExitThread退出是在C代码线程的首选方法。然而,在C + +代码,该线程退出之前,可以称为析或任何其他自动清理可以执行。因此,在C + +代码,您应该回到您的线程函数。
当此函数被调用(明示或由一个线程程序返回),当前线程的堆栈释放所有等待的I / O发起的线程被取消,该线程终止。入口点的所有连接的动态链接库(DLL)函数被调用,显示该线程是从DLL分离的价值。
如果线程是当这个函数被调用的进程,线程的过程,也是最后一个线程终止。
该线程对象的状态变为信号,释放任何已为线程等待其他线程终止。线程的终止由STILL_ACTIVE地位的变化对dwExitCode参数的值。
终止线程不一定删除操作系统的线程对象。一个线程对象被删除时的最后处理的线程被关闭。
PRB:ExitProcess期间,ExitThread,CreateThread,CreateRemoteThread的功能,这一过程已经开始(作为一个调用CreateProcess的结果)是序列彼此之间在一个过程。只有对这些事件可以发生在一个地址空间一次。这意味着持有下列限制:
在进程启动和DLL初始化例程,新的线程可以被创建,但他们没有开始执行,直到DLL初始化是完成这一进程。
只有一个线程在一个进程可以在DLL初始化或分离一次例行。
PRB:ExitProcess期间不会返回,直到没有线程在DLL初始化例程或分离。
一个可执行文件链接到静态的C运行时库(CRT)应该使用,而不是CreateThread和ExitThread _beginthread和_endthread的线程管理线程。如果不这样做的结果小内存泄漏当线程调用ExitThread。 Another work around is to link the executable to the CRT in a DLL instead of the static CRT.请注意,此内存泄漏只从一个DLL时,如果该DLL链接到静态CRT和一个线程调用DisableThreadLibraryCalls功能。否则,它是安全的调用在一个DLL线程CreateThread和ExitThread,为的静态CRT联系。
使用GetExitCodeThread函数检索线程的退出代码。
实例
有关示例,请参阅使用事件对象。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
CreateProcess的
CreateRemoteThread的
CreateThread
PRB:ExitProcess期间
FreeLibraryAndExitThread
GetExitCodeThread
OpenThread
进程和线程函数
TerminateThread
主题
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==ExitThread Function
Ends the calling thread.
Syntax
C++
VOID WINAPI ExitThread(
__in DWORD dwExitCode
);
Parameters
dwExitCode [in]
The exit code for the thread.
Return Value
This function does not return a value.
Remarks
ExitThread is the preferred method of exiting a thread in C code. However, in C++ code, the thread is exited before any destructors can be called or any other automatic cleanup can be performed. Therefore, in C++ code, you should return from your thread function.
When this function is called (either explicitly or by returning from a thread procedure), the current thread's stack is deallocated, all pending I/O initiated by the thread is canceled, and the thread terminates. The entry-point function of all attached dynamic-link libraries (DLLs) is invoked with a value indicating that the thread is detaching from the DLL.
If the thread is the last thread in the process when this function is called, the thread's process is also terminated.
The state of the thread object becomes signaled, releasing any other threads that had been waiting for the thread to terminate. The thread's termination status changes from STILL_ACTIVE to the value of the dwExitCode parameter.
Terminating a thread does not necessarily remove the thread object from the operating system. A thread object is deleted when the last handle to the thread is closed.
The ExitProcess , ExitThread, CreateThread , CreateRemoteThread functions, and a process that is starting (as the result of a CreateProcess call) are serialized between each other within a process. Only one of these events can happen in an address space at a time. This means the following restrictions hold:
During process startup and DLL initialization routines, new threads can be created, but they do not begin execution until DLL initialization is done for the process.
Only one thread in a process can be in a DLL initialization or detach routine at a time.
ExitProcess does not return until no threads are in their DLL initialization or detach routines.
A thread in an executable that is linked to the static C run-time library (CRT) should use _beginthread and _endthread for thread management rather than CreateThread and ExitThread. Failure to do so results in small memory leaks when the thread calls ExitThread. Another work around is to link the executable to the CRT in a DLL instead of the static CRT. Note that this memory leak only occurs from a DLL if the DLL is linked to the static CRT and a thread calls the DisableThreadLibraryCalls function. Otherwise, it is safe to call CreateThread and ExitThread from a thread in a DLL that links to the static CRT.
Use the GetExitCodeThread function to retrieve a thread's exit code.
Examples
For an example, see Using Event Objects .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
CreateProcess
CreateRemoteThread
CreateThread
ExitProcess
FreeLibraryAndExitThread
GetExitCodeThread
OpenThread
Process and Thread Functions
TerminateThread
Threads
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms682659(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:23:09