#include #include #include #include volatile int x=0; void* timer_1s(void *vargp){ for(int i=0; i<10; i++){ sleep(1); // wait 1s printf("1s-Tick\n"); x++; } return NULL; } void* timer_2s(void *vargp){ for(int i=0; i<5; i++){ sleep(2); printf("2s-Tick, t=%ds\n", x); } return NULL; } int main(){ pthread_t thread_1 = 0; pthread_t thread_2 = 0; printf("Wir starten nun beide Timer:\n"); pthread_create(&thread_1, NULL, timer_1s, NULL); pthread_create(&thread_2, NULL, timer_2s, NULL); pthread_join(thread_1, NULL); pthread_join(thread_2, NULL); printf("Wir sind nun fertig mit dem Programm, tschüss!\n"); return 0; }