如何 sleep /等待一秒钟?
我能找到的最好的东西是这样的(在 iex 中):
IO.puts "foo" ; :timer.sleep(1); IO.puts "bar"
但是我的两次看跌期权都立即发生。
最佳答案
计时器使用毫秒而不是秒,更新为:
IO.puts "foo" ; :timer.sleep(1000); IO.puts "bar"
Erlang 文档中的 :timer 文档:
Suspends the process calling this function for Time amount of milliseconds and then returns ok, or suspend the process forever if Time is the atom infinity. Naturally, this function does not return immediately.
关于Elixir sleep /等待 1 秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37106593/