[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Thread and join
From: |
Marcelo Dalmas |
Subject: |
Re: Thread and join |
Date: |
Fri, 11 Jan 2002 15:57:55 -0300 (EST) |
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