Golang指数退避算法
更新:HHH   时间:2023-1-7


package main

import (
    "fmt"
    "time"
)

const MAXSLEEP = 128

func 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)
        }
    }
}
返回编程语言教程...