急多线程有关问题

急啊。。。多线程问题!
我使用类封装了一个功能。。。

在这个类里面有两个线程。。。创建的。

然后给他们传递参数 
线程参数是 一个结构体

struct tagaa
{
  DWORD dwId; //这个是线程唯一标识符,用来区分两个线程做的事情
  void *pClass; //指向自身类的指针。
}
这个结构体传进去后。。。
开始运行


运行的时候 我调试 VS提示我 在 ****地方有未处理异常。在**地方发生了访问冲突

比如 
tagaa structtag = *(tagaa *)lparam;
class *pclass = (class *)pclass 
while (pclass->athreadisrun) //这里就提示了,
另外一个线程也是
while (pclass->bthreadisrung) //这里也会提示 还有就是只要我在线程里面使用 pclass 访问类资源都提示这个 访问冲突。。。为什么?

------解决方案--------------------
传的是栈上的东西,使用时,可能已经析构了
直接传类的指针
线程的id在线程内和启动线程时,都可以直接得到
------解决方案--------------------
你需要保证你传递给线程函数的参数必须有效?
------解决方案--------------------
pClass是有效指针吗,你怎传递线程参数的代码贴出来啊,包括创建参数结构,要用new 等堆内存或全局的,不能有函数局部的哦
------解决方案--------------------
在堆上分配指针,再传
------解决方案--------------------
探讨

void class::ccthread()
{
tagaa structa;
tagaa structb;
structa.dwid = 1;
structa.pthis = this;
structb.dwid = 2;
structb.pthis = this;
createthread(....,Threadfunc……

------解决方案--------------------
void class::ccthread()
{
tagaa structa = new tagaa();
tagaa structbnew tagaa();
structa->dwid = 1;
structa->pthis = this;
structb->dwid = 2;
structb->pthis = this;
createthread(....,Threadfunc,structa,...)
createthread(....,Threadfunc,structb,...)