Created
August 16, 2021 08:12
-
-
Save aarzilli/3fa0e50b627117cd0666303bacf743d4 to your computer and use it in GitHub Desktop.
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" | |
"runtime" | |
) | |
var globalvar1 = 0 | |
var globalvar2 = 0 | |
func main() { // Position 0 | |
runtime.LockOSThread() | |
globalvar2 = 1 | |
fmt.Printf("%d %d\n", globalvar1, globalvar2) | |
globalvar2 = globalvar1 + 1 | |
globalvar1 = globalvar2 + 1 | |
fmt.Printf("%d %d\n", globalvar1, globalvar2) // Position 1 | |
globalvar2 = globalvar2 + 1 // Position 2 | |
globalvar2 = globalvar1 + globalvar2 // Position 3 | |
fmt.Printf("%d %d\n", globalvar1, globalvar2) | |
globalvar1 = globalvar2 + 1 | |
fmt.Printf("%d %d\n", globalvar1, globalvar2) | |
done := make(chan struct{}) // Position 4 | |
go f(done) | |
<-done | |
} | |
func f(done chan struct{}) { | |
runtime.LockOSThread() | |
fmt.Printf("hello world!\n") | |
globalvar1 = globalvar2 + 1 | |
fmt.Printf("goodbye world!\n") | |
close(done) // Position 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment