public void solve(){
        int timeoutCell = 40;
        int timeoutGroup = 20;
        ArrayList<Thread> allThreads = new ArrayList<Thread>();
        for (int i=0; i < 81; i++){
           int[] xy = indexToXY(i);
           int x = xy[0];
           int y = xy[1];
            
           SudokuCellThread thread = new SudokuCellThread(this.sudokuField[y][x], timeoutCell);
           allThreads.add(thread);
        }
        //First collect all indices.
        //9 blocks 9 rows 9 colums are 27 groups
        //each group has 9 elements
        //each element has 2 components x and y to access it. 
        int[][][] sudokuGroups = new int[27][9][2];
        for(int i = 0; i < 9; i++){
            int blockTop = i/3*3;
            int blockLeft = i%3*3;
            for(int element=0; element < 9; element++){
                //rows
                sudokuGroups[i][element] = new int[]{i, element};
                //columns
                sudokuGroups[i+9][element] = new int[]{element, i};
                
                //blocks
                int y = element/3;
                int x = element%3;
                sudokuGroups[i+18][element] = new int[]{blockTop+y, blockLeft+x};
            }
        }
        //Then get the groups of SudokuCells according to the indices
        SudokuCell[][] sudokuCellGroups = new SudokuCell[27][9];
        for (int group=0; group < 27; group++){
            for(int element = 0; element < 9; element++){
                int[] address = sudokuGroups[group][element];
                int y = address[0];
                int x = address[1];
                sudokuCellGroups[group][element] = this.sudokuField[y][x];
            }
        }
         
        for (SudokuCell[] sudokuCellGroup: sudokuCellGroups){
            ArrayList<SudokuCell> sudokuCellGroupList = new ArrayList<SudokuCell>(Arrays.asList(sudokuCellGroup));
            SudokuGroupThread thread = new SudokuGroupThread(sudokuCellGroupList, timeoutGroup);
            allThreads.add(thread);
        }

        //StatusThread for debugging in test mode. Shows up the so far solved field when running mvn package.
        //Running as daemon
        //Thread statusThread = new SudokuFieldStatusThread(this.sudokuField);
        //statusThread.start();

        //Start all threads
        for (Thread thread: allThreads.toArray(new Thread[allThreads.size()])){
            thread.start();
        }
        //Wait for all threads to finish
        for (Thread thread: allThreads.toArray(new Thread[allThreads.size()])){
            try{
                thread.join();
            }
            catch (InterruptedException e){
            }
        }

         
    }