What is the best data structure with less time complexity in chat progrm?
I want to write a program that allows a number of clients to chat with each other or send files to each other. Also, one client can broadcast a message or a file to other clients.
I have a question about choosing the best data structure for messages.(We have n clients)
What is the best method for multi-client chat to avoid collisions?
I have a question about preventing race conditioning as I reading socket programming and multi thread in Java. Suppose we have many clients with one server. Clients chat through the server. Should we use Thread for each client or a queue that receives all clients requests to avoid thread collision? Or do you have a better suggestion?
If there is a code example in this field, I would be grateful if you could introduce it to me for a deeper understanding of the concepts
Thanks