O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

Follow these steps to implement the example:

  1. Start the example by implementing two auxiliary classes. First, create a class named MatrixMock. This class will generate a random matrix of numbers between one and 10, where the threads will look for a number:
        public class MatrixMock {
  1. Declare a private int matrix named data:
        private final int data[][];
  1. Implement the constructor of the class. This constructor will receive the number of rows of the matrix, the length of each row, and the number we are going to look for as parameters. All the three parameters are of the type int:
        public MatrixMock(int size, int length, int number){
  1. Initialize the variables and objects used in the constructor:
        int counter=0;  data=new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required