内容简介:执行结果
package main
import (
"runtime"
"sync"
"os"
"os/signal"
"syscall"
"fmt"
)
//定义函数类型
type Msg func(name string) string
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
wg := &sync.WaitGroup{}
c := make(chan os.Signal, 1)
handleMap := make(map[int]Msg)
handleMap[1] = handle1
handleMap[2] = handle2
handleMap[3] = handle3
signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
sig := <-c
_ = sig
s := handleMap[3]
s("测试")
wg.Done()
}()
wg.Add(1)
fmt.Println("执行任务~~~")
wg.Wait()
fmt.Printf("结束")
}
func handle1(name string) string {
fmt.Println(name)
return "handle1"
}
func handle2(name string) string {
fmt.Println("handle2")
return "handle2"
}
func handle3(tt string) string {
fmt.Println(tt)
return "handle3"
}
执行结果
执行任务~~~ 测试 结束 Process finished with exit code 0
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- Java构造函数与普通函数用法详解
- Oracle 中 decode 函数用法
- Oracle中的translate函数和replace函数的用法详解
- Oracle 中Contains 函数的用法
- Keras中几个重要函数用法
- Python map、reduce函数用法
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Algorithms on Strings, Trees and Sequences
Dan Gusfield / Cambridge University Press / 1997-5-28 / USD 99.99
String algorithms are a traditional area of study in computer science. In recent years their importance has grown dramatically with the huge increase of electronically stored text and of molecular seq......一起来看看 《Algorithms on Strings, Trees and Sequences》 这本书的介绍吧!