8.10   Parallel Execution

The HDevelop language supports the parallel execution of procedure and operator calls as subthreads of the main thread. Once started, subthreads are identified by a thread ID which is an integer process number depending on the operating system. The execution of subthreads is independent of the thread they have been started from. Therefore, the exact point in time when a specific threat finishes cannot be predicted. If you want to access data returned from a group of threads, it is required to explicitly wait for the corresponding threads to finish.

HDevelop limits the number of threads to 20 by default. This number can be modified in the preferences if required (see section “General Options ▹ General Options” on page 174). The main reason for limiting the number of simultaneous threads at all, is to prevent the user from inadvertently generating a huge number of threads due to a programming error. In that case, the system load as well as the memory consumption may grow so high that HDevelop can become unresponsive.

Please note that the thread count includes all threads that are “alive”. In particular it also includes threads that have already finished but are still being referenced by a variable. This has to be taken into account when tweaking the thread limit. See also section “Execution of Threads in HDevelop” on page 887 for information about the lifetime of a thread.