How many cooperative threads ?

Is there a limit on how many cooperative threads you can run simultaneously. ?

Yes, but there is no exact number and it varies across systems. Xojo threads are built on top of the native preemptive threading APIs, so maybe knowing that helps you a bit.

The limit is memory size.
So a 32 bit app can use about 3 GB. With maybe 3000 threads if you use 1 MB stack per thread.

PS: The question is for Windows?

well, even 100 threads may slow down a lot.
e.g. if a thread gets 20ms per run, with a 100 threads and one CPU you would only have a thread get time every 2 seconds.

Thanks Jean-Paul and Christian

Principal of cooperative threading.

Yes I am mostly on Windows

I am planning to build a 24/7 businessrule processor connected to several different types of database, as Windows service on a local server, and was just thinking about the approach that would work for me. Do think about helper-processes also, at least one to keep an eye on the main exe and the capability force stopping and starting it.

Well, as Xojo only uses one CPU at most, you may want to use helper processes.

I use a helper app that maintains an array of threads. A timer checks if any of them are completed and, if so, removes them from the array. As new jobs come in, they are added to the thread array. I set all their priorities to Lowest for two reasons: just in case the number of jobs goes very high and most of the threads are performing database lookups where the processing is done elsewhere.