niedziela, 13 grudnia 2020

pthread_create gcc

 #include <stdio.h>

#include <pthread.h>





int even_Numbers(int value)

{

if(value%2==0)

return 1;

else

return 0;

}

int odd_Numbers(int value)

{

if(value%2!=0)

return 1;

else

return 0;

}

void write_Even(void* sd)

{

int l=1;

while(1)

{

if(even_Numbers(l))

fprintf(stderr,"%d\n",l);

++l;

}

return NULL;

}

void write_Odd(void* sd)

{

int l=1;

while(1)

{

if(odd_Numbers(l))

fprintf(stderr,"%d\n",l);

++l;

}

return NULL;

}

pthread_t new_Thread;

int main()

{

pthread_create(&new_Thread,NULL,&write_Odd,NULL);

while(1)

write_Even(stderr);

return 0;

}

Brak komentarzy:

Prześlij komentarz