我写了一个类
想通过指针数组分别实例化8个
可是我发现实例化后的对象都不能用
subThread*  proThread[4];
这是我写的一个线程的类 实例化后
proThread[1]->
后面的功能都不能用了
谁能给个说法么?

解决方案 »

  1.   

    #include "stdafx.h"
    #include "NewThread.h"
    #include "subThread.h"
    #include "NewThreadDlg.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // subThreadIMPLEMENT_DYNCREATE(subThread, CWinThread)subThread::subThread()
    {
    }subThread::~subThread()
    {
    }BOOL subThread::InitInstance()
    {
    // TODO:  perform and per-thread initialization here
    AfxMessageBox("Hello!");
    return TRUE;
    }int subThread::ExitInstance()
    {
    // TODO:  perform any per-thread cleanup here
    return CWinThread::ExitInstance();
    }BEGIN_MESSAGE_MAP(subThread, CWinThread)
    //{{AFX_MSG_MAP(subThread)
    // NOTE - the ClassWizard will add and remove mapping macros here.
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // subThread message handlersint subThread::Run() 
    {
    // TODO: Add your specialized code here and/or call the base class
    AfxMessageBox("Good!");

    return CWinThread::Run();
    }这是一个线程类
    我在Dialog中创建了subThread*  proThread[4];
    如果我不是创建的线程数组就可以正确的调用
    可以创建了数组就不行了
      

  2.   

    proThread[1]=(subThread*)AfxBeginThread(RUNTIME_CLASS(subThread),THREAD_PRIORITY_ABOVE_NORMAL,0,CREATE_SUSPENDED);
    这是创建UI线程