Subj : question about the best way to proceed To : comp.programming.threads From : Luke Ehresman Date : Wed Mar 02 2005 10:59 am I have a question about the best way to solve a problem. I'm hoping to get some feedback from all of you. I have a multi-threaded application that manages sessions for multiple users. There is a thread in the background that does some processing on all the sessions constantly. My question is how to best iterate through the session list in that worker thread. I can't lock the session list and hold the lock while I do the processing because there may be a lot of sessions, and to do all the work on all the sessions would take a long time (and I would hold the lock for a very long time). Let me clarify a bit. I have two mutexes: one for the entire session list, and one for each individual session. The session list mutex is used to lock the list when doing operations on the list only. It is possible to be working on an individual session, but not hold the lock to the session list. Ideally, I would only lock the session I'm currently working with. But the problem is that I still need to iterate through all the sessions. When I finish working with that one session, I don't want to have to start back at the beginning of the session list (I would never get to the end!). Anyone have any thoughts on the best way to solve this? I have some ideas but I won't present them just yet because I don't want to taint your responses with my opinions. Luke .