GoLang
xxxxxxxxxx
package main
â
import (
"fmt"
"time"
)
â
func main() {
â
c1 := make(chan string, 1)
go func() {
time.Sleep(2 * time.Second)
c1 <- "result 1"
}()
â
select {
case res := <-c1:
fmt.Println(res)
case <-time.After(1 * time.Second):
fmt.Println("timeout 1")
}
â
c2 := make(chan string, 1)
go func() {
time.Sleep(2 * time.Second)
c2 <- "result 2"
}()
select {
case res := <-c2:
fmt.Println(res)
case <-time.After(3 * time.Second):
fmt.Println("timeout 2")
}
}
timeout 1 result 2
Linux - Comment installer anc-api-tools
Linux - Comment installer curvedns
Python - Vérifier si un nombre est positif, négatif ou 0
Linux - Comment installer zenmap
C - Compter le nombre de chiffres dans un entier
C++ - Vérifier l'année bissextile
JavaScript - VĂ©rifier si une chaĂźne commence et se termine par certains caractĂšres
C++ - VĂ©rifier si un nombre est premier ou non
C - Trouver le plus grand nombre à l'aide de l'allocation de mémoire dynamique
Linux - Comment installer xbitmaps
Kotlin - Arrondir un nombre à n décimales
Kotlin - Inverser un nombre
Linux - Comment installer zstd
Kotlin - Trouver la factorielle d'un nombre
Linux - Comment installer zfs-test
Java - Inverser un nombre
Kotlin - Calculer la somme des nombres naturels
Linux - Comment installer zita-ajbridge
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month