65,187
社区成员




#include <cstdlib>
#include <iostream>
#include <time.h>
#include <stdio.h>
#include <winsock2.h>
#include <windows.h>
#include <process.h>
#include <iostream>
#include <boost/shared_ptr.hpp>
boost::shared_ptr<int> p(new int(42));
unsigned int __stdcall threadfunA(void* arg)
{
while(1)
{
p.reset(new int(1));
Sleep(1);
}
return 0;
}
unsigned int __stdcall threadfunB(void* arg)
{
while(1)
{
p.reset(new int(1));
Sleep(1);
}
return 0;
}
int main()
{
HANDLE client;
client = (HANDLE) _beginthreadex (NULL, 0,
threadfunA, 0, 0 , NULL);
if (client == 0) {
printf ("error1 in _beginthreadex\n");
return -1;
}
HANDLE client2;
client2 = (HANDLE) _beginthreadex (NULL, 0,
threadfunB, 0, 0 , NULL);
if (client2 == 0) {
printf ("error2 in _beginthreadex\n");
return -1;
}
system("pause");
return 0;
}