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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay