定义
CWinThread* A;
CWinThread* B;
A=AfxBeginThread(functiona,null);
B=AfxBeginThread(functionB,null);其中functiona和functionB执行两个不同的循环,互不影响,我可以这样定义吗?可以在多线程中定义两个CWinThread对象吗?然后再分别停止两个线程

解决方案 »

  1.   

    停止程序
    if(A!=NULL)
    {
    HANDLE thread=m_arpspoofthread->m_hThread;
        if(thread!=NULL)

      BOOL res=TerminateThread(thread,0);
      if(!res)
      return false;
      A=NULL;

    if(B!=NULL)
    {
    HANDLE thread=m_arpspoofthread->m_hThread;
        if(thread!=NULL)

      BOOL res=TerminateThread(thread,0);
      if(!res)
      return false;
      B=NULL;

    不知行不行啊 }
      

  2.   

    dont use TerminateThread unless you have to……http://blog.joycode.com/jiangsheng/archive/2005/08/20/62256.aspx
      

  3.   

    让线程函数自己返回,不要使用TerminateThread
      

  4.   

    不要使用TerminateThread函数终止线程,这样系统没有机会清理堆栈上数据。如果你想在循环中也能退出,可用Event对象通知其退出,线程的循环体内用WaitForSingleObject(hEvent, 0)轮询hEvent的状态。