#include
#include
#include
void* thread(void* v)
{
char ch = *(char*)v;
sleep(1); //用于控制。
putchar(ch);
}
int main()
{
pthread_t id[7];
int i ,ret;
char str[] = "abcdefg";
for(i = 0; i < 7; ++i)
{
ret = pthread_create(&id[i],NULL,thread,&str[i]);
if(0 != ret)
{
printf("create pthread error\n");
i--;
}
}
for(i = 0; i < 7; ++i)
pthread_join(id[i],NULL);
printf("\n");
return 0;
}