Golang多線程刷票的實現代碼
直接用Go語言來寫下刷票。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package main import ( "fmt" "net/http" ) func vote(a chan int ) { for i := 0 ; i <= 1000 ; i++ { http.Get( "http://survey.news.ifeng.com/accumulator_ext.php?callback=jQuery1820030119983945041895_1490671752116&key=customLiveaway_support_552&format=js&_=1490671777810" ) } a <- 0 } func main() { a := make(chan int , 30 ) for i := 0 ; i < 30 ; i++ { go vote(a) } for b := range a { fmt.Println(b) } } |
上面的代碼能刷3W票。
隨隨便便,我就刷了接近30W票。
以上就是Golang多線程刷票的實現代碼的講解,大家如有疑問請留言或到社區討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
原文鏈接:https://my.oschina.net/u/248241/blog/869202