我目前正在尝试计算我请求网站的次数。在 python 中,我只会使用一个全局变量,但我不知道如何在 nim 中编写它。
import httpclient
proc threadMain(a: int) {.thread.} =
var client = newHttpClient()
while true:
try:
var r = client.getContent("URL")
echo "sent"
#Count here
except:
echo "error"
var thread: array[0..10, Thread[int]]
for i in 0..10:
thread[i].createThread(threadMain, i)
thread.joinThreads()
Run Code Online (Sandbox Code Playgroud) nim-lang ×1