Last active
April 18, 2019 20:17
-
-
Save yakuter/fd4f6dbc6b56ec40b2b7bd52b7fe822d to your computer and use it in GitHub Desktop.
Go Routine Örneği
This file contains 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" | |
"time" | |
) | |
func main() { | |
kahramanlar := []string{"Marvel", "Flash", "Thanos", "Flash", "Hulk", "Thor", | |
"Marvel", "Flash", "Thanos", "Flash", "Hulk", "Thor"} | |
go bulucuA(kahramanlar) | |
go bulucuB(kahramanlar) | |
fmt.Scanln() | |
} | |
func bulucuA(dizi []string) { | |
for i := 0; i < len(dizi); i++ { | |
if dizi[i] == "Flash" { | |
fmt.Println("Bulucu A: " + dizi[i] + " buldu") | |
} | |
time.Sleep(time.Second) | |
} | |
} | |
func bulucuB(dizi []string) { | |
for i := 0; i < len(dizi); i++ { | |
if dizi[i] == "Flash" { | |
fmt.Println("Bulucu B: " + dizi[i] + " buldu") | |
} | |
time.Sleep(time.Second) | |
} | |
} | |
/* UYGULAMA ÇIKTISI | |
Bulucu A: Flash buldu | |
Bulucu A: Flash buldu | |
Bulucu B: Flash buldu | |
Bulucu A: Flash buldu | |
Bulucu B: Flash buldu | |
Bulucu B: Flash buldu | |
Bulucu A: Flash buldu | |
Bulucu A: Flash buldu | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment