Skip to content

Instantly share code, notes, and snippets.

@liamzdenek
Created July 11, 2016 03:02
Show Gist options
  • Save liamzdenek/864b327bc660f4ab445f3729238f038b to your computer and use it in GitHub Desktop.
Save liamzdenek/864b327bc660f4ab445f3729238f038b to your computer and use it in GitHub Desktop.
package main
import (
"log"
"github.com/liamzdenek/go-pthreads"
)
func createThread(num int, url string) {
defer func() {
log.Println(num, "< kill_thread: done")
}()
log.Println(num, "> create_thread")
_ch := make(chan bool)
thread := pthread.Create(func() {
log.Println(num, "scraper")
_ch <- true;
})
log.Println("sleep 1", thread.Running())
<-_ch
log.Println("sleep 2", thread.Running())
thread.Kill()
log.Println("sleep 3")
}
func main() {
numThreads := 1000
for i := 1; i <= numThreads; i++ {
createThread(i, "https://google.com")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment