Todo:go language goroutine and channel use
Goroutine is a lightweight threading implementation in the Go language, managed by the Go Language runtime (runtime). When using the word "go" in front of the function as a keyword, it is also different from the normal function. You can create a new goroutine for concurrent execution by adding the Go keyword in front of the function.
Go Hello ()
The channel is a way of communication between the goroutine provided by the go language, and we can use the channel to deliver messages in two or more goroutine homes. The key word used by the channel is "Chan", which declares a channel with the type int:
var ch Chan int
Below is a small example of an event that is triggered when the listener process is closed.
Monitor the signal, use
Signal. Notify (c, OS. Interrupt)
The first parameter represents the channel that receives the signal
The second and subsequent parameters indicate the setting of the signal to be monitored, if not set to indicate that all signals are monitored.
Complete examples are as follows, in this case the service version of the Ubuntu14.04 test passed.
The effect of CTRL + C
Effects of the Kill process
Simple example, hope to help you.
Wxgzh:ludong86
Todo:go language goroutine and channel use