
Java 9 Concurrency Cookbook
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
- [*] This book takes a close look at the Java 9 APIs and their impact on concurrency
- [*] See practical examples on thread safety, high-performance classes, safe sharing, and a whole lot more
Book DescriptionWriting concurrent and parallel programming applications is an integral skill for any Java programmer. Java 9 comes with a host of fantastic features, including significant performance improvements and new APIs. This book will take you through all the new APIs, showing you how to build parallel and multi-threaded applications. The book covers all the elements of the Java Concurrency API, with essential recipes that will help you take advantage of the exciting new capabilities. You will learn how to use parallel and reactive streams to process massive data sets. Next, you will move on to create streams and use all their intermediate and terminal operations to process big collections of data in a parallel and functional way. Further, you'll discover a whole range of recipes for almost everything, such as thread management, synchronization, executors, parallel and reactive streams, and many more. At the end of the book, you will learn how to obtain information about the status of some of the most useful components of the Java Concurrency API and how to test concurrent applications using different tools.What you will learn - [*] Find out to manage the basic components of the Java Concurrency API
- [*] Use synchronization mechanisms to avoid data race conditions and other problems of concurrent applications
- [*] Separate the thread management from the rest of the application with the Executor framework
- [*] Solve problems using a parallelized version of the divide and conquer paradigm with the Fork / Join framework
- [*] Process massive data sets in an optimized way using streams and reactive streams
- [*] See which data structures we can use in concurrent applications and how to use them
- [*] Practice efficient techniques to test concurrent applications
- [*] Get to know tips and tricks to design concurrent applications
Who this book is forThe book is for Java developers and programmers at an intermediate to advanced level. It will be especially useful for developers who want to take advantage of task-based recipes using Java 9's concurrent API to program thread-safe solutions.
All prices
More details
Other editions
Additional editions

Person
Javier Fernandez is a software architect with almost 15 years experience with Java technologies. He has worked as a teacher, researcher, programmer, analyst, writer and now as an architect in all types of projects related to Java, especially J2EE. As a teacher, has taught over 1000 hours of training in basic Java, J2EE and Struts framework. As a researcher, has worked in the field of information retrieval developing applications for processing large amounts of data in Java and has participated as co-author on several journal articles and conference presentations. In recent years, has worked on developing J2EE web applications for various clients from different sectors (public administration, insurance, healthcare, transportation,.). Currently he works as a software architect at Capgemini developing and maintaining applications for an insurance company. He is the author of the book Java 7 Concurrency Cookbook.
Content
- Cover
- Copyright
- Credits
- About the Author
- About the Reviewer
- www.PacktPub.com
- Customer Feedback
- Table of Contents
- Preface
- Chapter 1: Thread Management
- Introduction
- Creating, running, and setting the characteristics of a thread
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Interrupting a thread
- Getting ready
- How to do it...
- How it works...
- There's more...
- Controlling the interruption of a thread
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Sleeping and resuming a thread
- Getting ready
- How to do it...
- How it works...
- There's more...
- Waiting for the finalization of a thread
- Getting ready
- How to do it...
- How it works...
- There's more...
- Creating and running a daemon thread
- Getting ready
- How to do it...
- How it works...
- There's more...
- Processing uncontrolled exceptions in a thread
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using thread local variables
- Getting ready
- How to do it...
- How it works...
- There's more...
- Grouping threads and processing uncontrolled exceptions in a group of threads
- Getting ready
- How to do it...
- How it works...
- See also
- Creating threads through a factory
- Getting ready
- How to do it...
- How it works...
- See also
- Chapter 2: Basic Thread Synchronization
- Introduction
- Synchronizing a method
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using conditions in synchronized code
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Synchronizing a block of code with a lock
- Getting ready
- How to do it...
- How it works...
- There's more...
- Avoiding deadlocks
- See also
- Synchronizing data access with read/write locks
- Getting ready...
- How to do it...
- How it works...
- See also
- Using multiple conditions in a lock
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Advanced locking with the StampedLock class
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Chapter 3: Thread Synchronization Utilities
- Introduction
- Controlling concurrent access to one or more copies of a resource
- Getting ready
- How to do it...
- How it works...
- There's more...
- Fairness in semaphores
- See also
- Waiting for multiple concurrent events
- Getting ready
- How to do it...
- How it works...
- There's more...
- Synchronizing tasks in a common point
- Getting ready
- How to do it...
- How it works...
- There's more...
- Resetting a CyclicBarrier object
- Broken CyclicBarrier objects
- See also
- Running concurrent-phased tasks
- Getting ready
- How to do it...
- How it works...
- There's more...
- Registering participants in Phaser
- Forcing the termination of Phaser
- See also
- Controlling phase change in concurrent-phased tasks
- Getting ready
- How to do it...
- How it works...
- See also
- Exchanging data between concurrent tasks
- Getting ready
- How to do it...
- How it works...
- There's more...
- Completing and linking tasks asynchronously
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also...
- Chapter 4: Thread Executors
- Introduction
- Creating a thread executor and controlling its rejected tasks
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Executing tasks in an executor that returns a result
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Running multiple tasks and processing the first result
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Running multiple tasks and processing all the results
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Running a task in an executor after a delay
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Running a task in an executor periodically
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Canceling a task in an executor
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Controlling a task finishing in an executor
- Getting ready
- How to do it...
- How it works...
- See also
- Separating the launching of tasks and the processing of their results in an executor
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Chapter 5: Fork/Join Framework
- Introduction
- Creating a fork/join pool
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Joining the results of the tasks
- How to do it...
- How it works...
- There's more...
- See also
- Running tasks asynchronously
- How to do it...
- How it works...
- There's more...
- See also
- Throwing exceptions in the tasks
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Canceling a task
- Getting ready...
- How to do it...
- How it works...
- See also
- Chapter 6: Parallel and Reactive Streams
- Introduction
- Creating streams from different sources
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Reducing the elements of a stream
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Collecting the elements of a stream
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Applying an action to every element of a stream
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Filtering the elements of a stream
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Transforming the elements of a stream
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Sorting the elements of a stream
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Verifying conditions in the elements of a stream
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Reactive programming with reactive streams
- Getting ready
- How to do it...
- How it works...
- There's more...
- Chapter 7: Concurrent Collections
- Introduction
- Using non-blocking thread-safe deques
- Getting ready
- How to do it...
- How it works...
- There's more...
- Using blocking thread-safe deques
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using blocking thread-safe queue ordered by priority
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using thread-safe lists with delayed elements
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using thread-safe navigable maps
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using thread-safe HashMaps
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using atomic variables
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using atomic arrays
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using the volatile keyword
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Using variable handles
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Chapter 8: Customizing Concurrency Classes
- Introduction
- Customizing the ThreadPoolExecutor class
- Getting ready
- How to do it...
- How it works...
- See also
- Implementing a priority-based Executor class
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Implementing the ThreadFactory interface to generate custom threads
- Getting ready
- How to do it...
- How it works...
- There's more...
- Using our ThreadFactory in an Executor object
- Getting ready
- How to do it...
- How it works...
- See also
- Customizing tasks running in a scheduled thread pool
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Implementing the ThreadFactory interface to generate custom threads for the fork/join framework
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Customizing tasks running in the fork/join framework
- How to do it...
- How it works...
- See also
- Implementing a custom Lock class
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Implementing a transfer queue-based on priorities
- Getting ready
- How to do it...
- How it works...
- See also
- Implementing your own atomic object
- Getting ready
- How to do it...
- How it works...
- See also
- Implementing your own stream generator
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Implementing your own asynchronous stream
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Chapter 9: Testing Concurrent Applications
- Introduction
- Monitoring a Lock interface
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Monitoring a Phaser class
- Getting ready
- How to do it...
- How it works...
- See also
- Monitoring an Executor framework
- Getting ready
- How to do it...
- How it works...
- See also
- Monitoring a fork/join pool
- Getting ready
- How to do it...
- How it works...
- See also
- Monitoring a stream
- Getting ready
- How to do it...
- How it works...
- See also
- Writing effective log messages
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Analyzing concurrent code with FindBugs
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Configuring Eclipse for debugging concurrency code
- Getting ready
- How to do it...
- How it works...
- Configuring NetBeans for debugging concurrency code
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Testing concurrency code with MultithreadedTC
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Monitoring with JConsole
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Chapter 10: Additional Information
- Introduction
- Processing results for Runnable objects in the Executor framework
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Processing uncontrolled exceptions in a ForkJoinPool class
- How to do it...
- How it works...
- There's more...
- See also
- Using a blocking thread-safe queue for communicating with producers and consumers
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Monitoring a Thread class
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Monitoring a Semaphore class
- Getting ready
- How to do it...
- How it works...
- See also
- Generating concurrent random numbers
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Chapter 11: Concurrent Programming Design
- Introduction
- Using immutable objects when possible
- Getting ready
- How to do it...
- How it works...
- There's more...
- See also
- Avoiding deadlocks by ordering locks
- How to do it...
- How it works...
- There's more...
- See also
- Using atomic variables instead of synchronization
- Getting ready
- How to do it...
- How it works...
- See also
- Holding locks for as short time as possible
- Getting ready
- How to do it...
- How it works...
- See also
- Delegating the management of threads to executors
- Getting ready
- How to do it...
- How it works...
- See also
- Using concurrent data structures instead of programming yourself
- There's more...
- See also
- Taking precautions using lazy initialization
- Getting ready
- How to do it...
- How it works...
- Using the fork/join framework instead of executors
- Getting ready
- How to do it...
- How it works...
- See also
- Avoiding the use of blocking operations inside a lock
- Getting ready
- How to do it...
- How it works...
- See also
- Avoiding the use of deprecated methods
- Using executors instead of thread groups
- See also
- Using streams to process big data sets
- Getting ready
- How to do it...
- How it works...
- See also
- Other tips and tricks
- See also
- Index
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.
File format: ePUB
Copy protection: without DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Use a reader that can handle the file format ePUB, such as Adobe Digital Editions or FBReader – both free (see eBook Help).
- Tablet/Smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePUB works well for novels and non-fiction books – i.e., 'flowing' text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook does not use copy protection or Digital Rights Management
For more information, see our eBook Help page.