O'Reilly logo

Learning Network Programming with Java by Richard M Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The thread-per-request approach

In Chapter 1, Getting Started with Network Programming, we illustrated a simple multithreaded echo server. This approach is reintroduced here to provide a foundation for the use of threads in the remainder of the chapter.

The thread-per-request server

In this example, the server will accept requests for prices when given the name of a part. The implementation will use the ConcurrentHashMap class that supports concurrent access to the part name and price. In a multithreaded environment, concurrent data structures, such as the ConcurrentHashMap class, handle operations without the potential for data corruption. Also, this map is an example of caching, which can be useful in improving the performance of applications. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required