Relative Content

Tag Archive for javamultithreadingsockets

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