Execute a method every x seconds in C

后端 未结 4 1001
别那么骄傲
别那么骄傲 2021-01-06 00:29

Is there an example of a working timer that executes some function every x amount seconds using C.

I\'d appreciate an example working code.

4条回答
  •  情话喂你
    2021-01-06 00:55

    If we do not want threads, we could use sleep

    int time = 10;
    printf("time: %ds\n", time);
    int i = 0;
    while(i

    The stuff is started every 1s, so we hope it can be done in this duration, otherwise it must take care of resources.

提交回复
热议问题