Mastering concurrency programming with Java 8 master the principles and techniques of multithreaded programming with the Java 8 Concurrency API

Master the principles and techniques of multithreaded programming with the Java 8 Concurrency API About This Book Implement concurrent applications using the Java 8 Concurrency API and its new components Improve the performance of your applications or process more data at the same time, taking advan...

Descripción completa

Detalles Bibliográficos
Otros Autores: Fernández González, Javier, author (author)
Formato: Libro electrónico
Idioma:Inglés
Publicado: Birmingham : Packt Publishing 2016.
Edición:1st edition
Colección:Community experience distilled.
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009630070806719
Tabla de Contenidos:
  • Cover ; Copyright; Credits; About the Author; About the Reviewers; www.PacktPub.com; Table of Contents; Preface; Chapter 1: The First Step - Concurrency Design Principles ; Basic concurrency concepts; Concurrency versus parallelism; Synchronization; Immutable object; Atomic operations and variables; Shared memory versus message passing; Possible problems in concurrent applications; Data race; Deadlock; Livelock; Resource starvation; Priority inversion; A methodology to design concurrent algorithms; The starting point - a sequential version of the algorithm; Step 1 - analysis; Step 2 - design
  • Step 3 - implementationStep 4 - testing; Step 5 - tuning; Conclusion; Java concurrency API; Basic concurrency classes; Synchronization mechanisms; Executors; The Fork/Join framework; Parallel streams; Concurrent data structures; Concurrency design patterns; Signaling; Rendezvous; Mutex; Multiplex; Barrier; Double-checked locking; Read-write lock; Thread pool; Thread local storage; The Java memory model; Tips and tricks to design concurrent algorithms; Identify the correct independent tasks; Implement concurrency at the highest possible level; Take scalability into account
  • Use thread-safe APIsNever assume an execution order; Prefer local thread variables over static and shared when possible; Find the more easily parallelizable version of the algorithm; Using immutable objects when possible; Avoiding deadlocks by ordering the locks; Using atomic variables instead of synchronization; Holding locks for as short a time as possible; Taking precautions using lazy initialization; Avoiding the use of blocking operations inside a critical section; Summary; Chapter 2: Managing Lots of Threads - Executors ; An introduction to executors; Basic characteristics of executors
  • Basic components of the executor frameworkFirst example - the k-nearest neighbors algorithm; K-nearest neighbors - serial version; K-nearest neighbors - a fine-grained concurrent version; K-nearest neighbors - a coarse-grained concurrent version; Comparing the solutions; The second example - concurrency in a client/server environment; Client/server - serial version; The DAO part; The command part; The server part; Client/server - parallel version; The server part; The command part; Extra components of the concurrent server; Comparing the two solutions; Other methods of interest; Summary
  • Chapter 3: Getting the Maximum from Executors Advanced characteristics of executors; Cancellation of tasks; Scheduling the execution of tasks; Overriding the executor methods; Changing some initialization parameters; The first example - an advanced server application; The ServerExecutor class; The statistics object; The rejected task controller; The executor tasks; The executor; The command classes; The ConcurrentCommand class; Concrete commands; The server part; The ConcurrentServer class; The RequestTask class; The client part; The second example - executing periodic tasks
  • The common parts