sleep()  may be implemented using SIGALRM; mixing calls to alarm(2) and
       sleep() is a bad idea.

 

sleep和usleep不能使用的原因不是什么线程不安全.而是在某些平台上这两个函数可能会使用SIGALRM,导致程序其他位置的定时机制失效。

实际程序中根本就不应该出现sleep和usleep,如果非要休眠不可,应考虑nanosleep或者select

相关文章:

  • 2021-06-19
  • 2022-12-23
  • 2021-04-29
  • 2021-09-05
  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2021-09-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
  • 2021-07-09
相关资源
相似解决方案