When the main thread exits, all active threads are immediately
terminated. Since your main subroutine has nothing after the
pthread_create(), it immediately exits, thus your secondary thread has no
chance to run.
Add a delay at the end of the main thread to give the pthread_create() the
time it needs, or just pthread_join() to wait until the secondary thread
terminates.
Ken Bolingbroke
[EMAIL PROTECTED]
On Sun, 26 Dec 1999, Steffen Merkel wrote:
> Hello,
>
> I'm learning C now for some weeks and today I wanted to program
> POSIX threads. Unfortunately my source seems not to run. Could you
> please have a look at my code and tell me whats wrong:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <pthread.h>
>
> void print( char *string ){
> fprintf(stderr,"String: %s\n",string);
> }
>
> void main(void){
> pthread_t thread;
> char string[] = "Hallo";
>
> if( pthread_create( &thread, (const pthread_attr_t *)NULL, (void *)&print,
> &string ) != 0 ){
> perror("pthread_create()");
> exit(EXIT_FAILURE);
> }
>
> }
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message