To understand the simple Java Socket Thread sever, we need to know the Networking and Thread. This post presents a simple sockets-based program to introduce the concepts of sockets and multi-threaded programming.
First, you need to know What are Sockets and know how client and server communicates. Second, if you only have single thread of sever, your client is waiting in queue. So a multi-threaded program performs multiple tasks at one time such as fielding simultaneous requests from many client programs.
The Socket Communications can give you a whole picture.
Update: This post uses Thread per connection, if you want to know how to do Thread per request, you can check “How NIO web server can rescue Reverse Ajax”.
1. Server Thread Code for Java
2. Sockets programming in Java
3. Advanced Socket Programming
4. A process-driven approach to avoid thread death
5. Programming Java threads in the real world, Part 8
6. Sockets programming in Java
7. Write your own threaded discussion forum: The communications and server components, part 2