Created
July 11, 2016 03:20
-
-
Save liamzdenek/afa4f4b5d8b1e8ce1df8ca2756d13d69 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; | |
_ch <- true; | |
}) | |
log.Println("sleep 1", thread.Running()) | |
<-_ch; | |
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