Re: POSIX thread question
- From: "Jack" <junw2000@xxxxxxxxx>
- Date: 28 Aug 2006 20:14:22 -0700
Mikko Rauhala wrote:
On 28 Aug 2006 14:15:21 -0700, Jack <junw2000@xxxxxxxxx> wrote:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Below is simple code of POSIX thread from a book:[snip]
It creates 10 threads. My questions are:
1. The 10 threads share the same code. Do the 10 threads share both
main() and myThread(), or just myThread()?
Everything, though if myThread() exits, it will not return to main()
but terminate the thread. myThread _can_ for example call main() if
How to do
it?
After the following line is executed:
ret = pthread_create( &threadIds[i], NULL, myThread, NULL );
The ith thread is created, then the ith thread enters myThread()
function and remains there, right?
The following line is in main() function:
ret = pthread_mutex_destroy( &cntr_mutex );
Only the 10 threads' parent process can execute the above line and
destroy the cntr_mutex. The 10 threads can not destroy the cntr_mutex
since they do not execute main() function, right?
Thanks.
Jack
.
- Follow-Ups:
- Re: POSIX thread question
- From: David Schwartz
- Re: POSIX thread question
- References:
- POSIX thread question
- From: Jack
- Re: POSIX thread question
- From: Mikko Rauhala
- POSIX thread question
- Prev by Date: Re: POSIX thread question
- Next by Date: Re: POSIX thread question
- Previous by thread: Re: POSIX thread question
- Next by thread: Re: POSIX thread question
- Index(es):