chat client receiving 2 or more concurrent messages
posted 6 years ago
Hi everyone. I'm facing a small problem. I created a simple text chat system, and the server is build in java. everything worked great until I started to test it with more clients.
So the idea is that one client can talk with multiple clients in the same time(similar to instant messaging software). The problem is when the client received 2 or more messages in the same time. it skips some of them.
On the server side I use a ThreadPoolExecutor to send the messages, every time it is required to send a message to a client I just create a runnable task and schedule it to the ThreadPool , but this way it is a possibility to send 2 messages in the same time to a certain client.
I think my problem can be solved by not sending more that one message in the same time to one client . SO I'm asking for some help, in case you can give me an idea of how to implement this using a threadpoolexecutor or if you have a better idea.