Site Search:

From concurrent to Parrallel

<Back

Chapter 1 to 5 are the foundation of java concurrency. We pay attention to locks, atomicity, visibility. We need to worry about final, static, volatile, stack confinement, thread local and invariant constraints on state variables, sometimes we even dig down into cpu cache, memory, system bus size, compiler optimization in order to understand a thread safe class. Those machine details are important when good program goes bad and your boss is in despair; however, life don't have to be that miserable, we have libraries and tools, which encapsulate those machinery under simple interfaces. We as driver just have to know how to drive and obey the traffic rules.

In the following chapters, we will study ExecutorService, Runnable and Callable interfaces. Runnable and Callable encapsulate the amount of work a thread need to handle, then submit them as objects to ExecutorService, which handle concurrency for us.

Java concurrency in practice were written before java 7 and java 8. Java 7 introduced Fork/Join framework, java 8 introduced parallel stream, both make Java concurrency more powerful and easier to use. While walking through the book examples, I plan to have the code written in Java 8 way whenever possible.

Here is a video from Brain Gotez about the trend of java concurrency.