역시나 기본 콘솔 프로젝트에 그대로 복사하시면 됩니다.
즐빌하세요 ^.^
//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#pragma hdrstop
#define BOOST_THREAD_USE_LIB
#include <boost/thread/thread.hpp>
#include <boost/scoped_ptr.hpp>
using boost::thread;
using boost::scoped_ptr;
#pragma argsused
struct myst
{
public:
myst() { printf("hi i'm myst\n"); }
void operator() ()
{
sayHello();
}
void sayHello()
{
while( true )
{
static int i = 0;
printf("hello\n");
i++;
Sleep(300);
if( i == 10 ) break;
}
}
};
int main(int argc, char* argv[])
{
scoped_ptr<boost::thread> mythread( new boost::thread(myst()) );
printf("hey?\n");
Sleep(900);
printf("hey!\n");
boost::thread* p = mythread.get();
mythread->join();
printf("end\n");
system("pause");
return 0;
}
//---------------------------------------------------------------------------
|