I am working on designing a multi-user application and would like to have a singleton service class that is shared amongst all of the user threads.
Within this class, I would like to have a method that does some heavy lifting to eventually compile a seperate list for each user, I am under the impression that since this is a method, each user thread will recieve its own sperate copy of this on its call stack.
Since this process is time consuming, I would like create multiple threads within the method to handle the processing and add items to a single list that was declared and instantiated within the method.
In the end I am envisioning a list complete list for each user that will then be able to be used throughout the rest of the application within the users thread.
My question is: How do accomplish sharing the list declared in the method amongst the multiple threads I want to create within the method while maintaining thread safety?
The flow chart below may explain everything better