Skip to content

xuges/gothread

Repository files navigation

gothread

Overview

Use consistent API to operate threads in Go language.

Supported OS:

Windows √

Linux √

MacOS √

Usage

import this package:

import "github.com/xuges/gothread"

Get current thread id:

id := gothread.GetId()
fmt.Println("current thread id:", id)

Pin to current thread:

gothread.Pin()
defer gothread.Unpin()

Run on thread stack:

// run on current thread
gothread.Run(func() {
    println(gothread.GetId())
})

// run on new thread
go gothread.Run(func() {
    println(gothread.GetId())
})

About

Threads API in Golang.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors