Book Image

Java 9 Programming By Example

By : Peter Verhas
Book Image

Java 9 Programming By Example

By: Peter Verhas

Overview of this book

This book gets you started with essential software development easily and quickly, guiding you through Java’s different facets. By adopting this approach, you can bridge the gap between learning and doing immediately. You will learn the new features of Java 9 quickly and experience a simple and powerful approach to software development. You will be able to use the Java runtime tools, understand the Java environment, and create Java programs. We then cover more simple examples to build your foundation before diving to some complex data structure problems that will solidify your Java 9 skills. With a special focus on modularity and HTTP 2.0, this book will guide you to get employed as a top notch Java developer. By the end of the book, you will have a firm foundation to continue your journey towards becoming a professional Java developer.
Table of Contents (17 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Chapter 5. Extending the Game - Run Parallel, Run Faster

In this chapter, we will extend the Mastermind game. As it is now, it can guess the secret that was hidden and also hide the pegs. The test code can even do both at the same time. It can play against itself leaving us only with the fun of programming. What it cannot do is make use of all the processors that we have in today's notebooks and servers. The code runs synchronous and utilizes only a single processor core.

We will alter the code extending the guessing algorithm to slice up the guessing into subtasks and execute the code in parallel. During this, we will get acquainted with Java concurrent programming. This will be a huge topic with many subtle corners and caveats lurking in the dark. We will get into those details that are the most important and will form a firm base for further studies whenever you need concurrent programs.

As the outcome of the game is the same as it was, only faster, we have to assess what faster is. To...