............
Printable View
............
Try debugging the code with some println statements to show execution flow and how variable values are changing.
Or to get help here, can you strip your code down and post all of the code so we can see what is happening.
I see three calls to new Brett( .. but only two of them call the start() method afterwards.
Where in your code does it find a solution to the first row?
Sorry, I don't understand your language. So I can't read your variable names or comments.
Was there a missing start() call?
What about this one?
Have you tried adding debugging println statements so you can see how the execution flows? When I did, the code created and started 2 threads.Quote:
//lager et nytt board
board = new Board(str, numberOfRowsInBox, numberOfColumnsInBox, squares);
}
if i only use brett.copy() when it finds a solution to first row on this board:
6
2
3
..1..3
......
....2.
26....
...3..
3..1.2
i get:
421563
000000
000020
260000
000300
300102
421653
000000
000020
260000
000300
300102
451263
000000
000020
260000
000300
300102
521463
000000
000020
260000
000300
300102
521643
000000
000020
260000
000300
300102
541263
000000
000020
260000
000300
300102
621453
000000
000020
260000
000300
300102
621543
000000
000020
260000
000300
300102
641253
000000
000020
260000
000300
300102
651243
000000
000020
260000
000300
300102
but when i use this in
Board b = new Board(str, numberOfRowsInBox, numberOfColumnsInBox, board.copy());
it will only start this first thread, but not the rest. It should start 10 threads, and from those 10 it should find 28 solutions
Why do you think that?Quote:
should start 10 threads
Put in some println() statements to show when and why the program creates threads.Quote:
Have you tried adding debugging println statements so you can see how the execution flows? When I did, the code created and started 2 threads.
I guess because there are 10 solution like this:
421563
000000
000020
260000
000300
300102
and whenever it finds one of this it is supposed make a new board and start(); which will call the recursive method from (1, 0) and continue solving the board.
After adding println statements I found out it stopped after making a new board() in the recursive method. So i wonder if the threads are trying to work on the same board. Have I missed any pointers to the new board or something?
Use println() to display what board a thread is working on.Quote:
wonder if the threads are trying to work on the same board.
Again use some println() to display what is seen at different points in the program.Quote:
Have I missed any pointers to the new board or something?