Maybe you have to run the code multiple times, but here (macOS and Windows) sooner or later the errors occur...
Code: Select all
InitNetwork()
Procedure TestThread(Nr)
Protected Response$ = ""
Protected HttpRequest = HTTPRequest(#PB_HTTP_Post, "https://www.purebasic.com/", "" + Str(Nr))
If HTTPRequest
Response$ = HTTPInfo(HTTPRequest, #PB_HTTP_Response)
FinishHTTP(HTTPRequest)
Debug Str(Nr) + " --> " + StringByteLength(Response$)
EndIf
EndProcedure
NewList Threads()
For k = 1 To 25
AddElement(Threads())
Threads() = CreateThread(@TestThread(), k)
Next
ForEach Threads()
WaitThread(Threads())
Next
But the result is:
Code: Select all
0 --> 25684
13 --> 25684
4 --> 25684
2 --> 25684
15 --> 25684
8 --> 25684
24 --> 25684
25 --> 25684
23 --> 25684
12 --> 25684
6 --> 25684
10 --> 25684
19 --> 25684
3 --> 566
17 --> 566
7 --> 566
22 --> 25684
9 --> 566
5 --> 566
18 --> 566
21 --> 566
1 --> 25684
20 --> 566
11 --> 566
14 --> 566
16 --> 566