This looks like homework.
It would be best if you did your own homework. It is given to you so that you will learn something, think about what have been taught. Read your text books and give it a try.
Some resources to help you:Prime number
]C multi-threading search
Once you have code and run into problems you can always come back here with a more specific question and the community will do its best to help you. Don't forget to post only the relevant code bits that pose the problem as a code dump is not usually helpful at all in getting someone to help/assist you.
Good luck and happy coding.