Speed. Aside from caffeine, nothing quickens the pulse of a programmer as
much as the blazingly fast execution of a piece of code. How can we fulfill
the need for computational speed? Moore’s law takes us some of the way,
but multicore is the real future. To take full advantage of multicore, we need
to program with concurrency in mind.
In a concurrent program, two or more actions take place simultaneously.
A concurrent program may download multiple files while performing computations
and updating the database. We often write concurrent programs
using threads in Java. Multithreading on the Java Virtual Machine (JVM)
has been around from the beginning, but how we program concurrency is
still evolving, as we’ll learn in this book.
The hard part is reaping the benefits of concurrency without being burned.
Starting threads is easy, but their execution sequence is nondeterministic.
We’re soon drawn into a battle to coordinate threads and ensure they’re
handling data consistently.