public static Matrix multiplyThread(Matrix matrixA, Matrix matrixB) throws
            IllegalSizesException, MatrixIndexOutOfBoundsException {

        Matrix matrixC = null;
        int rowsA = matrixA.getRowsCount();
        int colsA = matrixA.getColsCount();
        int rowsB = matrixB.getRowsCount();
        int colsB = matrixB.getColsCount();

        System.out.println("Multitread multiplication of matrixes A " + rowsA
                + "x" + colsA + " and B" + rowsB + "x" + colsB + ".");

        if ((rowsA != colsB) && (colsA != rowsB)) {
            throw new IllegalSizesException("Illegal matrix dimensions.");
        }

        dataTypeA = matrixA.getDataType();
        dataTypeB = matrixB.getDataType();
        //creates the matrix analising data type of matrixes A and B
        if (dataTypeA.equals(dataTypeB)) {
            matrixC = MatrixSelector.getMatrix(rowsA, colsB, DataType.getDataType(dataTypeA));
            //throw new IncorrectFormatOfData("Data of matrixes are not identical.");
        } else {
            matrixC = MatrixSelector.getMatrix(rowsA, colsB, DataType.DOUBLE);
        }

        System.out.println("Type of data is " + dataTypeA + ".");

        //defines quantity of necessary thread
        int quantityOfStreams;
        if (rowsA <= 100) {
            quantityOfStreams = 1;
        } else if (rowsA < 1000) {
            //The maximum number of processors available to the virtual machine
            quantityOfStreams = Runtime.getRuntime().availableProcessors();
        } else {
            //The maximum number of threads else size of the matrix >= 1000
            quantityOfStreams = 2 * Runtime.getRuntime().availableProcessors();
        }
        
        Thread[] thrd = new Thread[quantityOfStreams];

        long startTime = System.currentTimeMillis();
        
        for (int i = 0; i < quantityOfStreams; i++) {
            thrd[i] = new Thread(new MultiplyThread(matrixA, matrixB, matrixC));
            thrd[i].start(); //thread start

        }

        for (int i = 0; i < quantityOfStreams; i++) {
            try {
                thrd[i].join(); // joining threads
            } catch (InterruptedException e) {
                System.out.println("Exception of tread.");
            }
        }

        //run time
        long endTime = System.currentTimeMillis();
        long time = endTime - startTime;
        System.out.println("Multiplication of matrixes lasted " + time + " ms.");
        setZeroRowsForThread();

        return matrixC;
    }