到底 go 语言程序设计要不要考虑多线程问题,另求 go 在 windows 创建多线程代码例子。
因为多线程设计可以少考虑很多问题,让程序设计没有那么复杂,尤其是兼容单 cpu 单核问题上。
1
gamexg 2018 年 7 月 6 日 via Android
需要考虑,建议看 go 内存模型 。
|
2
jmone 2018 年 7 月 7 日
尼玛,就这水平还定能顶替 2-3 个 php
|
5
a7a3 2018 年 7 月 20 日
package main
import ( "C" "fmt" "syscall" ) func ThreadProc(p uintptr) uintptr { fmt.Println("hello a7a2") return 0 } func main() { modkernel32 := syscall.MustLoadDLL("kernel32.dll") procCreateThread := modkernel32.MustFindProc("CreateThread") r1, _, _ := procCreateThread.Call(0, 0, syscall.NewCallback(ThreadProc), 0, 0, 0) h := syscall.Handle(r1) syscall.WaitForSingleObject(h, syscall.INFINITE) syscall.CloseHandle(h) } |