Created
September 1, 2015 00:50
-
-
Save JamsMendez/1444dc9c1a38c896d513 to your computer and use it in GitHub Desktop.
Concurrencia en Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
func main() { | |
var wg sync.WaitGroup | |
wg.Add(2) | |
fmt.Println("Starting Go Routines") | |
go func() { | |
defer wg.Done() | |
time.Sleep(10 * time.Second) | |
fmt.Println("Finish Rutina 1") | |
}() | |
go func() { | |
defer wg.Done() | |
time.Sleep(12 * time.Second) | |
fmt.Println("Finish Rutina 2") | |
}() | |
fmt.Println("Waiting To Finish") | |
wg.Wait() | |
fmt.Println("Finish...") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment