Answers for "sleep in go"

1

golang sleep

package main

import (
    "fmt"
    "time"
)

func main() {
    fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())

    time.Sleep(2 * time.Second)

    fmt.Printf("Current Unix Time: %v\n", time.Now().Unix())
}
Posted by: Guest on November-28-2020
1

sleep n seconds in go

/*
this is golang code but the
java syntax highlighting was
good, so yeah
*/
package main
import (
	"fmt"
	"time"
)

func main() {
	for i := 1; i <= 5; i++ {
    	fmt.Println(i)
        time.Sleep(1 * time.Second) // for 1 second
        time.Sleep(1 * time.Millisecond) // for 1 millisecond
    }
}
Posted by: Guest on March-22-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language