C++Builder2010创建线程

New菜单项中有专门的线程模板,以下是模板生成的cpp:

 


__fastcall myt::myt(bool CreateSuspended)
    : TThread(CreateSuspended)
{
    FreeOnTerminate=true;
}

void __fastcall myt::xx()
{
    //---- Place thread code here ----
    for(int i=1;i <4;i++)
        Form1->Edit3->Text = Form1->Edit3->Text+"我得" + this->xxx;
}
//---------------------------------------------------------------------------
void __fastcall myt::Execute()
{
    //---- Place thread code here ----
    Synchronize(&xx);   //调用主窗体的控件一定要用Synchronize
}

 

//调用时代码

 

    myt *my = new myt(false);
    my->Priority =tpIdle;    //优先级
    my->xxx="ssd";
    int i =  my->Suspended;
    //my->Start()       ;
   my->Resume();
 

 

 

 

posted @ 2011-01-28 12:47  81  阅读(424)  评论(0编辑  收藏  举报