In one of my Project i need to run two operations( Open & Close Operations ) at a same time(i.e., parallel/simultaneously). I've created two threads for respective Operation like this:

```
UINT MyThread1(LPVOID lParam)
{
 // code for Open Operation..
 // other stuffs...

 return(1);
}

UINT MyThread2(LPVOID lParam)
{
 //Code for Close Operation..
 //Other Stuffs..

return(1);
}

void CMyProject : OnbnClickedOpen()
{
   // Here am running OPen Operation Continously..
 while(1) {
 AfxBeginThread(MyThread1,0);
 }
 }

void CMyProject : onbnClickedClose()
{
  //Here am running Close Operation continously...
  while(1) {
  AfxBeginThread(MyThread2,0);
 }
}

```

Here am not able to run the threads continuously. I've tried an alternative way like this:

```
void CMyProject : OnbnClickedOpen()
{
   while( 1 )
   {
     //Code for Open Operation..
   }
 }

void CMyProject : onbnClickedClose()
{
  while(1)
  {
    //Code for Close Operation..
  }
}

```

With this i can run either Open Operation Continuously or close operation Continuously but not both at at time.

Please Sugest/guide me how to do this..

Thanks.