There were already lots of helpful discussions here, but I just wanted to drop this in case it helps getting the overall design of the multi-threaded part right:
(But it is also a good idea to check whether the library you are using has some problems with threading.)