Skip to content

Instantly share code, notes, and snippets.

@ecylmz
Created February 4, 2013 20:36
Show Gist options
  • Save ecylmz/4709542 to your computer and use it in GitHub Desktop.
Save ecylmz/4709542 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"sync"
"time"
)
func main() {
m := new(sync.Mutex)
for i := 0; i < 10; i++ {
go func(i int) {
m.Lock()
fmt.Println(i, "start")
time.Sleep(time.Second)
fmt.Println(i, "end")
m.Unlock()
}(i)
}
var input string
fmt.Scanln(&input)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment