DEV Community

Cover image for Concurrency trong Go: Tạo goroutine
handuy
handuy

Posted on

1

Concurrency trong Go: Tạo goroutine

Video hướng dẫn cách tạo goroutine với từ khóa go:

Tham khảo code được sử dụng trong bài:

package main

import (
    "fmt"
)

func printNumber() {
    for i := 0; i <= 100; i++ {
        fmt.Printf("%d ", i)
    }
}

func printChar() {
    for i := 'A'; i < 'A'+26; i++ {
        fmt.Printf("%c ", i)
    }
}

func main() {
    go printNumber()
    go printChar()
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more