Created
May 27, 2016 06:40
-
-
Save vgangireddyin/f39f5bb089529383cf8a57d2becb63c6 to your computer and use it in GitHub Desktop.
Go Routine
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 Publish(text string, delay time.Duration) { | |
/** | |
* Create a thread at os level and shedule by go sheduler | |
*/ | |
go func() { | |
time.Sleep(delay) | |
fmt.Println("Latest News:", text) | |
}() | |
} | |
func main() { | |
Publish("some random note", 5*time.Second) | |
fmt.Println("this may publish before latest one") | |
time.Sleep(10*time.Second) | |
fmt.Println("After 10 Sec: final act") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment