Subj : Re: Freeing data structures in a threaded application To : comp.programming.threads From : David Schwartz Date : Wed Feb 16 2005 01:30 pm "Joe Seigh" wrote in message news:opsma65mgwqm36vk@grunion... > You can use reference counting to protect the session data. You only > free the session data when the last reference is dropped. This works pretty well. If you need objects to timeout, you can create a 'has timed out' flag that starts out off and start the reference count at one. When the object times out, check to make sure the 'has timed out' flag is clear, set the flag, and decrement the reference count. When it hits zero, you delete it. This allows you to lock an object, increment its reference count, and then unlock it, secure in the knowledge that other threads can use it, but it will not disappear out from under you. DS .