Esempio n. 1
0
func (j *MyJob) Run(t tq.TimeSetter) {
	if j.nr_exec_times >= 3 {
		fmt.Printf("I'm tired, I will stop.\n")
		t.Stop()
		j.ch <- true
		return
	}
	if j.backoff == 0 {
		j.backoff = 2
	} else {
		j.backoff <<= 1
	}
	t.After(j.backoff)
	fmt.Printf("Hello, I have been executed %d time(s).\n", j.nr_exec_times)
	j.nr_exec_times++
}