Book Image

Java 7 New Features Cookbook

By : Richard M. Reese, Jennifer L. Reese
Book Image

Java 7 New Features Cookbook

By: Richard M. Reese, Jennifer L. Reese

Overview of this book

<p>Java 7 is a major update that includes a lot of exciting new language improvements such as support for type inference and improved exception handling. Other new features include the ability to work with symbolic links, a greatly simplified directory traversal technique, and the monitoring of file creation and deletion. Improvements in event handling, security, and concurrent processing have also been added<br /><br />Java 7 New Features Cookbook is your go-to guide to learn about all the new exciting features Java 7 has to offer with a very practical recipe-based approach. <br /><br />The book starts with coverage of the new language improvements. Subsequent chapters address the new features of Java 7 while incorporating these new language improvements when possible.<br /><br />The new NIO techniques provide enhanced capabilities which are complemented by the new try-with-resources block and enhanced generic support. The new JLayer decorator and improved window methods enhance the developer&rsquo;s ability to create GUI applications. <br /><br />The Java 7 New Features Cookbook provides a comprehensive coverage of the exciting features in Java 7.</p>
Table of Contents (18 chapters)
Java 7 New Features Cookbook
Credits
About the Authors
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface

Chapter 10. Concurrent Processing

In this chapter, we will cover the following:

  • Using join/fork framework in Java 7

  • Using the reusable synchronization barrier Phaser

  • Using the ConcurrentLinkedDeque class safely with multiple threads

  • Using the LinkedTransferQueue class

  • Supporting multiple threads using the ThreadLocalRandom class

Introduction

Support for concurrent applications has been improved in Java 7. Several new classes have been introduced that support the parallel execution of tasks. The ForkJoinPool class is used for applications, which use the divide-and-conquer technique to solve a problem. Each subproblem is forked (split) as a separate thread and later joined, if necessary to provide a solution. The threads used by this class are normally subclasses of the java.util.concurrent.ForkJoinTask class and are lightweight threads. The use of this approach is illustrated in the Using join/fork framework in Java recipe.

In addition, the java.util.concurrent.Phaser class has been introduced to...