May’s Packt Publishing Prize Draw – Java 7 Features

9 May

Do You Know Java Seven?

This month we are offering just one book in the competition because every Java developer needs to read it, or one like it.

The book is “Java 7 – New Features Cookbook” by the father and daughter team Richard and Jennifer Reese.

Java 7 arrived in July last year after nearly half a decade of waiting.  It brings useful new features that we all need to master if we are to stay relevant.

The New Features Cookbook provides solid, practical examples to help you get to grips with these new features.  It helps you to gain a proper understanding of what they are for and how they are used.

If you want to have a chance of winning one of this months books then please sign up on the Meetup page.  At the end of March the lucky winner will get a physical copy with an ebook for the runner up.

Let’s cover a few examples of the new features and how the cookbook introduces them.

Concurrent Processing

The free lunch ended years ago, and no developer can afford to ignore concurrent programming.  To make our life easier Java 7 introduces the join/fork framework and the Phaser synchronization barrier.

The join/fork framework allows us to break a problem down into smaller parts, work on them in parallel and then bring it all back together at the end.   The Reese’s introduce us to the framework using an example that calculates the sum of square both iteratively and using fork/join and compares how long the two approaches.  The fork/join isn’t necessarily faster.

The Phaser is useful when you have threads working together in cyclical phases.  It waits for all the threads in one phase to complete before starting the next.  This time a mock game engine is created with each player represented by a task.   The Phaser is used to co-ordinate their activities, synchronising when a set of tasks will start.

Automated Resource Management

We have always needed to be careful to close our resources or suffer the consequences.  Try with resources makes safely working with resource much easier.  The resources being managed automatically are declared as we enter the try block and released as we exit.  The book demonstrates their use by copying a file using buffered streams.  Suppressed exceptions and structuring issues are also explained.

User Interface Improvements

Swing has gained a new few tricks.  If your client is filthy rich you can deck it out with new bling like windows that are translucent and irregularly shaped.  Some simple examples show translucent windows with gradients and an octagonal shape.  Not every operating system can support it and the examples show how to check the graphics environment for support.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: