Are Thread IDs assigned in a deterministic manner using TPool

From Support
Jump to: navigation, search

Question:

Are the thread IDs assigned within a TPool deterministic so one can use these values in an implementation? For example assume threadMax set to 10: 3 requests thread number given 1-ID3 2-ID4 3-ThreadID 5 Processed returned to TPool Will 4th request use new thread with ID 6 say instead of 3,4,or 5

Answer:

Even once the thread pool is fully populated, there is no guarantee that the same set of threads will remain in the pool, as the OAD will swap the listener thread with a thread in the pool when doing so will result in better performance. The ability to pin down specific threads to specific functions is part of the Thread Per Object policy that will be coming in VB 4.0.

Article originally contributed by Jimmy Maher