Free Sample
+ Collection

Java 7 Concurrency Cookbook

Javier Fernández González

Master multithreaded program development with this Java 7 concurrency cookbook. Packed with real-world solutions, it takes you from basic to more sophisticated aspects of concurrency. For intermediate to advanced Java developers.
RRP $29.99
RRP $49.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849687881
Paperback364 pages

About This Book

Master all that Java 7 has to offer for concurrent programming Get to grips with thread management, the Fork/Join framework, concurrency classes and much more in this book and e-book A practical Cookbook packed with recipes for achieving the most important Java Concurrency tasks

Who This Book Is For

If you are a Java developer who wants to take your knowledge of concurrent programming and multithreading further, as well as discover the new concurrency features of Java 7, then "Java 7 Concurrency Cookbook" is for you.You should already be comfortable with general Java development practices and a basic grasp of threads would be an advantage.

Table of Contents

Chapter 1: Thread Management
Creating and running a thread
Getting and setting thread information
Interrupting a thread
Controlling the interruption of a thread
Sleeping and resuming a thread
Waiting for the finalization of a thread
Creating and running a daemon thread
Processing uncontrolled exceptions in a thread
Using local thread variables
Grouping threads into a group
Processing uncontrolled exceptions in a group of threads
Creating threads through a factory
Chapter 2: Basic Thread Synchronization
Synchronizing a method
Arranging independent attributes in synchronized classes
Using conditions in synchronized code
Synchronizing a block of code with a Lock
Synchronizing data access with read/write locks
Modifying Lock fairness
Using multiple conditions in a Lock
Chapter 3: Thread Synchronization Utilities
Controlling concurrent access to a resource
Controlling concurrent access to multiple copies of a resource
Waiting for multiple concurrent events
Synchronizing tasks in a common point
Running concurrent phased tasks
Controlling phase change in concurrent phased tasks
Changing data between concurrent tasks
Chapter 4: Thread Executors
Creating a thread executor
Creating a fixed-size thread executor
Executing tasks in an executor that returns a result
Running multiple tasks and processing the first result
Running multiple tasks and processing all the results
Running a task in an executor after a delay
Running a task in an executor periodically
Canceling a task in an executor
Controlling a task finishing in an executor
Separating the launching of tasks and the processing of their results in an executor
Controlling rejected tasks of an executor
Chapter 5: Fork/Join Framework
Creating a Fork/Join pool
Joining the results of the tasks
Running tasks asynchronously
Throwing exceptions in the tasks
Canceling a task
Chapter 6: Concurrent Collections
Using non-blocking thread-safe lists
Using blocking thread-safe lists
Using blocking thread-safe lists ordered by priority
Using thread-safe lists with delayed elements
Using thread-safe navigable maps
Generating concurrent random numbers
Using atomic variables
Using atomic arrays
Chapter 7: Customizing Concurrency Classes
Customizing the ThreadPoolExecutor class
Implementing a priority-based Executor class
Implementing the ThreadFactory interface to generate custom threads
Using our ThreadFactory in an Executor object
Customizing tasks running in a scheduled thread pool
Implementing the ThreadFactory interface to generate custom threads for the Fork/Join framework
Customizing tasks running in the Fork/Join framework
Implementing a custom Lock class
Implementing a transfer Queue based on priorities
Implementing your own atomic object
Chapter 8: Testing Concurrent Applications
Monitoring a Lock interface
Monitoring a Phaser class
Monitoring an Executor framework
Monitoring a Fork/Join pool
Writing effective log messages
Analyzing concurrent code with FindBugs
Configuring Eclipse for debugging concurrency code
Configuring NetBeans for debugging concurrency code
Testing concurrency code with MultithreadedTC

What You Will Learn

Master the basics of thread management and synchronization before diving into higher level concurrency tasks Get to grips with exciting new concurrency features of Java 7, including the Phaser Class and the Fork/Join Framework Successfully delegate thread management to executors Customize some of the most useful classes of the Java concurrency API with real-world examples Learn to use high-level Java utilities to manage synchronization between threads Get a sneak peek at using Eclipse and NetBeans for debugging concurrency code Avoid problems with data inconsistency by learning the data structures you have to use in concurrent applications Take advantage of a bonus appendix packed with tips that every programmer should consider when developing a concurrent application

In Detail

Java remains the global standard for developing various applications and enterprise software, and the launch of Java 7 brings with it exciting new capabilities for concurrent programming by way of the concurrency utilities enhancement. This allows developers to make the most of their applications with parallel task performance. "Java 7 Concurrency Cookbook" covers all elements of the Java concurrency API, providing essential recipes for taking advantage of the exciting new capabilities.On your computer, you can listen to music while you edit a Word document and read your emails, all at once! This is because your operating system allows the concurrency of tasks, much like the Java platform which offers various classes to execute concurrent tasks inside a Java program. "Java 7 Concurrency Cookbook" covers the most important features of the Java concurrency API, with special emphasis on the new capabilities of version 7. With each version, Java increases the available functionality to facilitate development of concurrent programs. This book covers the most important and useful mechanisms included in version 7 of the Java concurrency API, so you will be able to use them directly in your applications."Java 7 Concurrency Cookbook" includes recipes to enable you to achieve everything from the basic management of threads and tasks, to the new Fork /Join framework, through synchronization mechanisms between tasks, different types of concurrent tasks that Java can execute, data structures that must be used in concurrent applications and the classes of the library that can be customized.With the step-by-step examples in this book you’ll be able to apply the most important and useful features of the Java 7 concurrency API.


Read More