热门IT资讯网

Golang指数退避算法

发表于:2024-11-28 作者:热门IT资讯网编辑
编辑最后更新 2024年11月28日,package mainimport ( "fmt" "time")const MAXSLEEP = 128func main() { for numsec := 1; numsec
package mainimport (    "fmt"    "time")const MAXSLEEP = 128func main() {    for numsec := 1; numsec <= MAXSLEEP; numsec <<= 1 {        // TODO        if numsec <= MAXSLEEP/2 {            time.Sleep(time.Second * time.Duration(numsec))            fmt.Println("slepp time(s):", numsec)        }    }}
0