diff --git a/lec13/th3.c b/lec13/th3.c index 4c5006b507681d351c054cde578c60116990f082..2ec2f10c40ecea94ec85c69890000c31bcbeaca7 100644 --- a/lec13/th3.c +++ b/lec13/th3.c @@ -1,33 +1,35 @@ #include <stdio.h> #include <sys/types.h> #include <unistd.h> - -int bbb = 0; - + +int bbb = 0; + void fn_s() { - char bufff[10]; - static int a = 0; - setvbuf(stdout,bufff, _IOFBF,10); - printf("== %d %d ==",a++, bbb++); + static int a = 0; + printf("== %d %d ==\n",a++, bbb++); } - + void *run (void *arg) { - printf("Hello world of POSIX threads.%d\n", (int) (0)); - for (int i = 0; i < 10; i++) + printf("Hello world of POSXI threads.%d\n", (int) (0) ); + for (int i = 0; i < 100; i++) { - sleep(1); - fn_s(); + sleep(1); + fn_s(); } - return 0; - + return 0; + } - + int main() { int result1; - run((void *) 0); - printf("Thread return %d at the end\n", result1); + run((void *) 0); + sleep(10); + + run((void *) 0); + printf("Thread return %d at the end\n", result1); } +