"Segmentation fault" means nothing more and nothing less than "your program tried to use a chunk of memory that was not assigned to it." That's a wild-behavior of the program which could happen for any number of reasons, none of which have anything to do with threading.
It is, however, somewhat more likely to be some kind of a timing problem. So maybe the very first thing to do is to establish that the threads really are
being created... then start carefully debugging your code. Some things to consider:
- Are you, in fact, using synchronization objects (mutexes, locks, etc.) in a well-planned and "correct" way?
- Are you properly initializing those objects?
- Are there any possible "timing holes" at all?
- Are you properly initializing all memory-blocks... is there any possibility of a "stale" or uninitialized pointer?
Most of the time, such diagnoses require some very careful "desk checking," because when a segmentation-fault happens it is usually down in the bowels of some runtime library, far away both in time and in space from where the real
source of the problem lies.
It is fairly unrealistic to hand a program to a forum and say, "debug it for me!
", but if you can post moderate and specific snippets we may be able to help you more.