Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
该Unix.sleep函数可以暂停程序整秒,但你怎么能暂停它不到一秒呢?
Unix.sleep
经典的 Unix 解决方案是使用不带文件描述符的 select():
let minisleep (sec: float) = ignore (Unix.select [] [] [] sec)
该Thread.delay函数将线程暂停给定的秒数,但它需要一个浮点数,允许您暂停线程不到一秒。
Thread.delay
来自Unix模块
val sleepf : float -> unit
在给定的秒数内停止执行。与睡眠类似,但支持几分之一秒。