Threading Test

BlitzMax Forums/BlitzMax Programming/Threading Test

BLaBZ(Posted 2013) [#1]
Hi All -

I'm attempting to run some threading test though everytime I run this code the IDE freezes and windows prompts me to debug the application.

Is anyone else able to run this?

Local array:TThread[3]

Local sc:Int = MilliSecs()
For Local x:Int = 0 To array.length - 1
	array[x] = CreateThread(Loop,Null)
Next
Local ec:Int = MilliSecs()

Print (ec - sc)

Print "Waiting on Threads..."

Local sm:Int = MilliSecs()
For x = 0 To array.length
	WaitThread(array[x])
Next
Local em:Int = MilliSecs()

Print (em - sm)


Function Loop:Object(data:Object)
	Local sm:Int = MilliSecs()
	Local list:TList = CreateList()
	For Local x:Int = 0 To 1000000
		list.addlast(New SimpleType)
	Next
	Local em:Int = MilliSecs()
	Return Null
End Function 


Type SimpleType
	Field Val:String
End Type



BLaBZ(Posted 2013) [#2]
Nvm my array index was out of bounds, strange that debugging threaded applications it doesn't always display what went wrong...


BLaBZ(Posted 2013) [#3]
Nvm my array index was out of bounds, strange that debugging threaded applications it doesn't always display what went wrong...


Brucey(Posted 2013) [#4]
You can always use "Until", which means you don't need to remember to take 1 from the length :
For Local x:Int = 0 Until array.length



col(Posted 2013) [#5]
+1 for suggesting 'Until'. I use it ALL the time and rarely use 'For...To'. This should so be in the manual.