C++/Use of List with a Singleton Class
I am trying to explain a scenario which i tried, I have a singleton class, and when the Instance is created I am creating a List<ListItem Class>. Im the main thread I have a method which is adding Items into the List ( using push_back), and in this method, I am creating a workerthread with a method which will iterate through the list and remove the entries based on a Condition. Do I need to use any kind of locking mechanism?. I am totally new to this C++. Please Help me.
Yes, you would need to synchronize access to the list. This is the classical producer-consumer scenario.