bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Not running properly..........


From: Srinivasa T.N.
Subject: Re: Not running properly..........
Date: Wed, 30 May 2001 20:13:27 +0530

Is there not a method like pthread_join??  (so that my main thread can wait until other threads exit...)

Regards,
Seenu.

David Sugar wrote:

Your main thread exits before all your subthread's get a chance to execute.
The exit joins threads since it deletes allocated objects thru the
destructors.  If you add a Sleep() before exiting main the other threads will
have a chance to run and delete themselves.

Srinivasa T.N. wrote:

> Hi,
>     Can anybody tell me why this program is not running properly.
>
> (see attachment for the program).
>
> The o/p is
>
> Before Thread1 start
> Before Thread2 start
> Thread1 Initial()
> Run() of thread1
>
>
> Regards,
> Seenu.
>
> Note: I am using Common C++ 1.3.2, egcs -2.91.66, and Redhat 6.2 on a
> i686 m/c (Kernel 2.2.14)
>
> --
> -----------------------------------------------------------------------------
> If not here, you can reach me at address@hidden
>
> C-DOT, 71/1, Sneha Complex, Miller Road, Bangalore - 560 052
> Ph: 226 3399 Ext: 268  Direct: 238 3951 (Off)
>     363 1707 (Resi)
>
>
>
>
> ------------------------------------------------------------------------
>
> #include <cc++/config.h>
> #include <cc++/macros.h>
> #include <cc++/thread.h>
> #include <cc++/socket.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> class Thread1 : public Thread
> {
> private:
>       void Initial()
>               { cout << "Thread1 Initial() " << endl;}
>       void Run();
>       void Final()
>               { delete this;};
> };
>
> class Thread2 : public Thread
> {
> private:
>       void Initial()
>               { cout << "Thread2 Initial() " << endl;}
>       void Run();
>       void Final()
>               { delete this;};
>
> };
>
> int main()
> {
>       Thread1 *thread1 = new Thread1;
>       Thread2 *thread2 = new Thread2;
>
>       cout << "Before Thread1 start " << endl;
>       thread1->Start();
>       cout << "Before Thread2 start " << endl;
>       thread2->Start();
> }
>
> void Thread1::Run(void)
> {
>       cout << "Run() of thread1"  << endl;
> }
>
> void Thread2::Run(void)
> {
>       cout << "Run() of thread2"  << endl;
> }
> bug1.cpp
>
> Content-Type:
>
> text/plain
> Content-Encoding:
>
> 7bit

_______________________________________________
Bug-commoncpp mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/bug-commoncpp

-- 
-----------------------------------------------------------------------------
If not here, you can reach me at address@hidden

C-DOT, 71/1, Sneha Complex, Miller Road, Bangalore - 560 052
Ph: 226 3399 Ext: 268  Direct: 238 3951 (Off)
    363 1707 (Resi)
 
reply via email to

[Prev in Thread] Current Thread [Next in Thread]