You likely have a bug in your program, but I don't know if we can help you much without code. Have you tried to use debugging techniques to isolate the section of code that causes the problem? If not, that might be a good first step. Also, how are you compiling your code and can you print the exact error message that you're seeing?
As an aside, I'm curious why you posted this in Threads and Synchronization as I don't see much in your original post that deals with either. Perhaps you posted this
thread in the wrong forum?