首页 > IT职业 > IT职场 > Golang指数退避算法
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) } }}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4380/viewspace-2817595/ ,如需转载,请注明出处,否则将追究法律责任。