Multi-threaded Client/Server Chat Applications in java

A chat application consists of a chat server and a chat client. The server accepts connections from the clients and delivers all messages from each client to other clients. This is a tool to communicate with other people over Internet in real time.

The client is implemented using two threads - one thread to interact with the server and the other with the standard input. Two threads are needed because a client must communicate with the server and, simultaneously, it must be ready to read messages from the standard input to be sent to the server.

The server is implemented using threads also. It uses a separate thread for each connection. It spawns a new client thread every time a new connection from a client is accepted. This simplifies a lot the design of the server. Multi-threading, however, creates synchronization issues. We will present two implementations of the chat server. An implementation that focus on multi-threading without considering the synchronization issues will be presented first. Then we will focus on the synchronization issues that a multi-threaded implementation creates. Finally, an updated version of the multi-threaded chat server that fixes the synchronization issues is presented.


Comments

Post a Comment

Popular posts from this blog

How to Install AnyDesk remote desktop client on Ubuntu

How to install Jaspersoft Studio on Eclipse

What is Advanced Encryption Standard (AEC) and online tool to encrypt and decrypt data using AEC.