June 2014
Intermediate to advanced
300 pages
7h 12m
English
As well as the enhanced locks we covered in day 2, java.util.concurrent contains a collection of general-purpose, high-performance, and thoroughly debugged concurrent data structures and utilities. Today we’ll see that more often than not, these prove to be a better choice than rolling our own solution.
In day 1 we saw how to start threads, but it turns out that it rarely makes sense to create threads directly. Here, for example, is a very simple server that echoes whatever it’s sent:
| ThreadsLocks/EchoServer/src/main/java/com/paulbutcher/EchoServer.java | |
| | public class EchoServer { |
| | |
| | public static void main(String[] args) throws IOException { |
| | |
| | class ConnectionHandler ... |
Read now
Unlock full access