public static void main(String[] args) {
        final double[][] matrix = generateMatrix(10, 1000000);
        evaluate(new Runnable(){

            @Override
            public void run() {
                for (int i = 0; i<matrix.length; i++){
                    for (int j = 0; j< matrix[i].length; j++){
                        double result = calculate(matrix[i][j]);
                    }
                }
            }
        });

        evaluate(new Runnable(){

            @Override
            public void run() {
                List<Thread> threads = new LinkedList<Thread>();
                for (int i = 0; i<matrix.length; i++){
                    Thread t = new Thread(new RowTask(matrix[i]));
                    threads.add(t);
                    t.start();
                }
                for (Thread t : threads){
                    try {
                        t.join();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
    }