Hi Martin,
Thanks a lot for your answer! I don't have much experience with multithreading and I will look into the tools you recommended. For the record, this particular problem seems to have been solved by Max's suggestion above.
Thanks and all the best, Botond