diff --git a/lec13/th3.c b/lec13/th3.c new file mode 100644 index 0000000000000000000000000000000000000000..2ec2f10c40ecea94ec85c69890000c31bcbeaca7 --- /dev/null +++ b/lec13/th3.c @@ -0,0 +1,35 @@ +#include <stdio.h> +#include <sys/types.h> +#include <unistd.h> + +int bbb = 0; + +void fn_s() +{ + static int a = 0; + printf("== %d %d ==\n",a++, bbb++); +} + + +void *run (void *arg) +{ + printf("Hello world of POSXI threads.%d\n", (int) (0) ); + for (int i = 0; i < 100; i++) + { + sleep(1); + fn_s(); + } + return 0; + +} + +int main() +{ + int result1; + run((void *) 0); + sleep(10); + + run((void *) 0); + printf("Thread return %d at the end\n", result1); +} +