Incidentally, your approach makes the prime function a bottleneck. You might be able to remove that by removing the global lock when finding new primes.
Just make sure to lock before each read and write and use indices instead of iterators.
Also, you may wish to get rid of your dependency on mpz_class. I don't see what it brings, and it means downloading yet another library and configure and set up for those that don't have it.
Might improve chances of getting an answer.