I have the following function that is run in an independent thread. There can be up to 100 of these threads running concurrently.