#include <pthread.h>
#include <stdio.h>
typedef struct thread_char_para {
char character;
int count;
} thread_char_para;
void* char_print (void* parameter)
{
thread_char_para* p = (thread_char_para*)parameter;
int i;
for (i = 0; i < p->count; ++i)
fputc(p->character, stderr);
return NULL;
}
int main()
{
pthread_t thread1;
pthread_t thread2;
thread_char_para para1 = {'x', 30000};
thread_char_para para2 = {'o', 30000};
pthread_create(&thread1, NULL, char_print, ¶1);
pthread_create(&thread2, NULL, char_print, ¶2);
return 0;
}
Why there is no any output?
I alse find some links to read: Detached vs. Joinable POSIX threads
in this link, it says pthread_join
is not necessary. So, i am wondering.