2 回答

TA貢獻(xiàn)1887條經(jīng)驗(yàn) 獲得超5個(gè)贊
例如,
package main
import "runtime"
func routine() {
runtime.LockOSThread()
runtime.UnlockOSThread()
}
func main() {
go routine()
}

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超4個(gè)贊
如有疑問(wèn),請(qǐng)參閱文檔。
func LockOSThread()
LockOSThread wires the calling goroutine to its current operating system thread.
Until the calling goroutine exits or calls UnlockOSThread, it will always execute in
that thread, and no other goroutine can.
func UnlockOSThread()
UnlockOSThread unwires the calling goroutine from its fixed operating system thread.
If the calling goroutine has not called LockOSThread, UnlockOSThread is a no-op.
- 2 回答
- 0 關(guān)注
- 308 瀏覽
添加回答
舉報(bào)