Goroutine
Golang was designed with concurrency as a first-class feature. Concurrency is achieved through goroutines and channels. This model is simple yet powerful.
Goroutines are lightweight threads managed by the Go runtime. They will be automatically multiplexed onto multiple OS threads when necessary. So there is no need to create and manage OS thread manualy.
package main
import (
"fmt"
"time"
)
func main() {
go fmt.Print(1)
go fmt.Print(2)
fmt.Print(3)
time.Sleep(time.Millisecond)
}
The output will be 312 or 321.