I have a server and 'x' number of clients.
When the server is listening for an inbound connection, it will create a client handler instance (a class that manages the client communication) which will be spun off in a separate thread.
Depending on the command the client sends to the server, the server may need to access a SQL database to store information about that client.
The client handler instance will 'handle' this request. The only problem is, if multiple client handlers are wanting to access the SQL database to do the exact same thing then there is potential for read / write issues.
I was thinking about exposing a static method on the server, calling it from the client handle instances, then locking the function which accesses the SQL database (either read or write).
Is this a good approach or are there better approaches?
Thanks.