bug-commoncpp
[Top][All Lists]
Advanced

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

Re: Thread and join


From: David Sugar
Subject: Re: Thread and join
Date: Fri, 11 Jan 2002 13:33:54 -0500 (EST)

If you delete the child thread with the delete operator from the main
thread, the main thread will suspend pending on the join.  Hence you only
need to do a delete.

On Fri, 11 Jan 2002, Marcelo Dalmas wrote:

> So, how to suspend the execution of main thread to wait a thread?
>
> With pthread i do:
> main ()
> {
>       pthread_t *thread;
>
>       pthread_create(thread);
>       do something;
>       pthread_join(thread);
>
>       return 0;
> }
>
> Now, with CommonC++ I do:
>
> main()
> {
>       MyThread *thread = new MyThread();
>
>       thread->Start();
>       do something;
>
>       while ( thread->isRunning() )  // why not thread->Join() ?
>               sleep(1);
>
>       delete thread;
>       return 0;
> }
>
> On Fri, 11 Jan 2002, David Sugar wrote:
>
> >
> > Join is an operation that occurs when a thread is deleted.  There is
> > little reason to have the thread exist once it is joined, and the thread
>
> I don't think so. If there are two indepents things to do, like add
> number, i could do :
>
>               |
>               ^
>             /   \
>         1+2+...   1+2+..
>            \    /
>              a+b
>
> > class is a container for the running execution context.  Hence, seperately
> > joining a thread is usually not a useful operation outside of deleting it,
> > although it can be done with the Terminate() member which performs a join.
> >
> >
>
> Thanks
>
> Marcelo Dalmas
> BRASMAP Sistemas
> www.brasmap.com.br
> Fone/Fax: (48) 333-2218 ramal 2114
>
>
>




reply via email to

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