What Can I Use Besides usleep in a Modern POSIX Environment?

前端 未结 5 1617
一向
一向 2021-01-19 05:04

I\'m fairly new to C but writing a small multithreaded application. I want to introduce a delay to a thread. I\'d been using \'usleep\' and the behavior is what I desire -

5条回答
  •  灰色年华
    2021-01-19 06:06

    You are probably on a modern POSIX system:

    POSIX.1-2008 removes the specification of usleep().

    On my system (linux) there is a detailed explanation of the macros that must be set to get that function back. But you should just follow the advice that zvrba already gave, use nanosleep instead.

提交回复
热议问题