前言 :
這裡介紹如何在Windows 利用函式 _beginthread, _beginthreadex下建立 Thread. (更多說明可以參考 這裡)
函式介紹 :
語法 :
參數 :
- start_address
- stack_size
- arglist
- security
- initflag
- thrdaddr
返回值 :
使用函式庫 :
Multithreaded versions of the C run-time libraries only.
To use _beginthread or _beginthreadex, the application must link with one of the multithreaded C run-time libraries.
使用範例 :
The following sample code demonstrates how you can use the thread handle returned by _beginthreadex with the synchronization APIWaitForSingleObject. The main thread waits for the second thread to terminate before it continues. When the second thread calls _endthreadex, it causes its thread object to go to the signaled state. This allows the primary thread to continue running. This cannot be done with _beginthread and _endthread, because _endthread calls CloseHandle, destroying the thread object before it can be set to the signaled state.
執行結果 :
補充說明 :
* C++ Multithread 簡單範例
這裡介紹如何在Windows 利用函式 _beginthread, _beginthreadex下建立 Thread. (更多說明可以參考 這裡)
函式介紹 :
語法 :
- uintptr_t _beginthread(
- void( *start_address )( void * ),
- unsigned stack_size,
- void *arglist
- );
- uintptr_t _beginthreadex(
- void *security,
- unsigned stack_size,
- unsigned ( *start_address )( void * ),
- void *arglist,
- unsigned initflag,
- unsigned *thrdaddr
- );
- start_address
- stack_size
- arglist
- security
- initflag
- thrdaddr
返回值 :
使用函式庫 :
Multithreaded versions of the C run-time libraries only.
To use _beginthread or _beginthreadex, the application must link with one of the multithreaded C run-time libraries.
使用範例 :
The following sample code demonstrates how you can use the thread handle returned by _beginthreadex with the synchronization APIWaitForSingleObject. The main thread waits for the second thread to terminate before it continues. When the second thread calls _endthreadex, it causes its thread object to go to the signaled state. This allows the primary thread to continue running. This cannot be done with _beginthread and _endthread, because _endthread calls CloseHandle, destroying the thread object before it can be set to the signaled state.
執行結果 :
補充說明 :
* C++ Multithread 簡單範例
This message was edited 4 times. Last update was at 06/08/2010 16:39:22
沒有留言:
張貼留言