23 Concurrency

Objectives

In this chapter you’ll:

  • Understand concurrency, parallelism and multithreading.

  • Learn the thread life cycle.

  • Use ExecutorService to launch concurrent threads that execute Runnables.

  • Use synchronized methods to coordinate access to shared mutable data.

  • Understand producer/consumer relationships.

  • Use JavaFX’s concurrency APIs to update GUIs in a thread-safe manner.

  • Compare the performance of Arrays methods sort and parallelSort on a multi-core system.

  • Use parallel streams for better performance on multi-core systems.

  • Use CompletableFutures to execute long calculations asynchronously and get the results in the future.

Get Java How To Program, Late Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.