Managing multiple threads with `local variables`

BlitzMax Forums/BlitzMax Programming/Managing multiple threads with `local variables`

The type is passed to the thread through the CreateThread() function. Just be sure to cast it when entering the thread, like this
Function Thread:Object(data:Object)
    Local ThreadData:TThread = TThread(data)
...etc
End Function

Local ThreadData:TThread = New TThread
Local ThreadHandle:Int = CreateThread(ThreadData)

To use it in a function, just pass the type to the function normally. Don't worry about speed. You are only passing the reference to the type which is really just an Int pointer. It is no slower than creating an array then passing an index to the function. Actually types may be more efficient since you will probably need to create some sort of referencing system for the array, or else the array can get quite huge.