help me in threads

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sedefy
    New Member
    • Sep 2010
    • 16

    help me in threads

    i work in VC++ win32 application
    i want to creat 2 threads th1 and th2
    th1 will run th2 and wait 10 second and increment a counter
    th2 will run 1 second and increment another counter
    during the 1 second of th2 it will run a small functions according to counters c1,c2 values
    each time th2 interrupt the running small programs to increment c2 when it come back the interrupted program should incremented from its last position not to start over again.i used beginthread method but the timing was not correct at all and here is my code:
    Code:
    /****************************************/
    void dispatcher()
    {
     function1();
     function2();
     .
     .
     .
     .
     .
     function();
    }
    void subframe(void *arg )
    {
    	
    	while(1)
    	{
    	 cout<<"\n Start SubFrame no"<<FScount.sub;
             _beginthread(dispatcher,0,NULL);
      	 wait(10000);
     	 sub++;
            }
    }
    /********************************************/
    void mainframe(void *arg )
    {
    while(1)
     {
      cout<<"\n ==Starting Frame No."<<FScount.frame<<"==";
      _beginthread(softInterrupt,0,NULL);
       wait(30000);
       FScount.frame++;
     }
    }
    /********************************************/
    void main(void)
    {
    	_beginthread(mainframe,0,NULL);
    }
Working...