I'd like to craete multithread program which uses hash_map (hash_map<int, vecotr<void *> >). I have 8-core machine so I don't want to lock hash_map every insert. I created 20000 phtread_rwlock's and when there is insert value using some key i do pthread_rwlock_wrlock(locks[key % 20000]) and during read I create pthread_rwlock_rdlock(locks[key % 20000]). That solution segfaults sometimes.