func (test *Test) MyThreadMsgCallBack1(thread *msgThread.Thread, infoObject interface{}) { fmt.Println("msgCallBack1", infoObject) info2 := "f**k from thread1 to thread2" msgObject2 := new(msgThread.MsgObject) msgObject2.Info = info2 thread2.SendMsg(msgObject2) }
func (test *Test) MyThreadCallBack2(thread *msgThread.Thread, info interface{}) { fmt.Println("thread2") time.Sleep(1 * time.Second) info1 := "111" msgObject1 := new(msgThread.MsgObject) msgObject1.Info = info1 thread1.SendMsg(msgObject1) }
func (test *Test) MyThreadCallBack1(thread *msgThread.Thread, info interface{}) { fmt.Println("thread1") time.Sleep(1 * time.Second) info2 := "222" msgObject2 := new(msgThread.MsgObject) msgObject2.Info = info2 thread2.SendMsg(msgObject2) }
func (test *Test) MyThreadMsgCallBack2(thread *msgThread.Thread, infoObject interface{}) { fmt.Println("msgCallBack2", infoObject) info1 := "f**k from thread2 to thread1" infoObject1 := new(msgThread.MsgObject) infoObject1.Info = info1 thread1.SendMsg(infoObject1) //可选是否关闭,一般不需要关闭,线程池关闭的时候,自动关闭此线程 //thread1.Stop() }