线程函数使用函数//error C3861: “_beginthreadex”: 即或使用参数相关

线程函数使用函数//error C3861: “_beginthreadex”: 即使使用参数相关


#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <time.h>
#include <iostream>
using namespace std;
HANDLE _thread_handle = NULL;
HANDLE _thread_handle2 = NULL;
int loop = 10000;
int loop_array[10000] = {0};
CRITICAL_SECTION g_cs; 

typedef void (*fptr)();
void test()
{
EnterCriticalSection(&g_cs); 
while(loop)
{
loop_array[loop - 1] = loop;
loop --;
}
LeaveCriticalSection(&g_cs);  
}
fptr fp = &test;

unsigned int __stdcall ThreadFunc(LPVOID para)
{
para();
return 0;
}


int _tmain(int argc, _TCHAR* argv[])
{
HANDLE thread_handle[2];  
thread_handle[0] = (HANDLE)_beginthreadex(NULL, 0, ThreadFunc, fp, 0, NULL);  
    thread_handle[1] = (HANDLE)_beginthreadex(NULL, 0, ThreadFunc, fp, 0, NULL);  

InitializeCriticalSection(&g_cs);   
clock_t t1 = clock();
WaitForMultipleObjects(2,thread_handle, TRUE, INFINITE);    
clock_t t2 = clock();

CloseHandle(thread_handle[0]);  
    CloseHandle(thread_handle[1]);  
    DeleteCriticalSection(&g_cs);
std::cout<<"time: "<<t2-t1<<std::endl;
return 0;
}

------解决方案--------------------
bool database_conrast(TCHAR* accessbase_path,TCHAR* splitebase_path) //函数原型
------解决方案--------------------
AfxBeginThread 会自动删除。

        CloseHandle(m_pThread[0]->m_hThread);  
        CloseHandle(m_pThread[1]->m_hThread);
不必要, 而且 会 出错。