Interesting other way to deal with this kind of situation is with Lock Free data structures. They're pretty complicated and I don't fully understand them, but http://erdani.com/publications/cuj-2004-10.pdf is a decent explanation of them. The fundamental idea behind them is that each thread assumes that they are the only one who is manipulating a structure, and then after they change it, they check to see if they were correct, and clean up. It's an interesting way to sometimes improve performance on shared memory systems.
Interesting other way to deal with this kind of situation is with Lock Free data structures. They're pretty complicated and I don't fully understand them, but http://erdani.com/publications/cuj-2004-10.pdf is a decent explanation of them. The fundamental idea behind them is that each thread assumes that they are the only one who is manipulating a structure, and then after they change it, they check to see if they were correct, and clean up. It's an interesting way to sometimes improve performance on shared memory systems.