package main
import "time" import "runtime" type T1 struct{ i int } type T2 struct{ i int } func main() { t1 := new(T1) t2 := new(T2) runtime.SetFinalizer(t1, func(*T1) {println(1)}) runtime.SetFinalizer(t2, func(*T2) {println(2)}) runtime.GC() time.Sleep(time.Second * 2) // the program will output: 2 // if I adjust the order of the declarations of t1 and t2, // the program will output: 1 } Why the finalizer for the first declaration will not get called? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.