How to implement thread which periodically checks something using minimal resources?

前端 未结 5 1638
长发绾君心
长发绾君心 2021-01-02 00:39

I would like to have a thread running in background which will check connection to some server with given time interval. For example for every 5 seconds.

I don\'t kn

5条回答
  •  庸人自扰
    2021-01-02 00:59

    If the thread runs for the life of the app, can be simply terminated by the OS on app close and does not need accurate timing, why bother with solutions that require more typing than sleep(5000)?

提交回复
热议问题