Created
July 11, 2016 03:02
-
-
Save liamzdenek/864b327bc660f4ab445f3729238f038b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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