Managing multiple threads with `local variables`

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

Let's assume I create a threaded BlitzMax app in which I set up x number of additional threads, besides the main one. This needs to be totally scalable so there could be 1 thread or 1000. This will be running on computers with multiple cores/cpu's.

Each thread will be executing exactly the same set of functions (and the list is quite long). It is not an option to duplicate any of the functions or to create a version of each function for each thread, because that's not scalable.

I want each individual thread to have kind of its own set of special `local variables`, or a single global variable which is an index of one dimension of a multidimensional array - just some way of isolating some data to be only used by that thread.

Each thread should access only the set of data `attached` to it, and not the data that other threads are using. Doing this with Processes is not an option (although processes do have local memory spaces). It's not just a matter of using mutexes, because mutexes are for isolating access to *shared* data, I need to actually get each thread its own unique set of data.

How do I make this work? Is there any way?