Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
func server(i int) { | ||
for { | ||
print(i) | ||
time.Sleep(1*1e9) | ||
} | ||
} | ||
|
||
/* | ||
* this will no output if default: export GOMAXPROCS=1 | ||
*/ | ||
func f1() { | ||
go server(1) | ||
go server(2) | ||
for {} | ||
} | ||
|
||
func f3() { | ||
go server(1) | ||
go server(2) | ||
for { | ||
time.Sleep(1*1e6) | ||
} | ||
} | ||
|
||
func f2() { | ||
go server(1) | ||
go server(2) | ||
time.Sleep(6*1000*1000) | ||
} | ||
|
||
func main() { | ||
f3() | ||
//f2() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
"fmt" | ||
) | ||
|
||
func IsReady(what string, minutes int64) { | ||
time.Sleep(minutes * 60 * 1e9) // Unit is nanosecs. | ||
fmt.Println(what, "is ready") | ||
} | ||
|
||
func main() { | ||
go IsReady("tea", 6) | ||
go IsReady("coffee", 2) | ||
fmt.Println("I'm waiting...") | ||
} |