fiveham / Sudoku_Solver

Solve sudoku puzzles by representing the puzzle as a bipartite graph of truth-claims about cells' values and rule-statements that have exactly one true neighbor and removing edges as information is added
MIT License
0 stars 0 forks source link

Solver's call to wait(100) is arbitrary, should call wait() (no args) instead #9

Open fiveham opened 8 years ago

fiveham commented 8 years ago

So far, attempts to use wait() have resulted in inconsistent thread suspension, where the main thread is notified after the last solver thread terminates but the main thread passes the test in the header of the while loop in which its call to wait() is located again and calls wait() again

Maybe repeating the while loop's header test in an if-statement inside the synchronized block in the while loop would enable this use of wait(). That would mean that the removal of the final solver thread from its thread group had not yet registered in terms of the output of ThreadGroup.activeCount() before the main thread checked that active count and would mean that the removal of the final solver thread from its thread group will have manifested in the output of ThreadGroup.activeCount() between the time when the main thread passes the header test and the time when the main thread gets the lock on the lock Object and entered the synchronized block inside the while loop.

Disclaimer: I don't really understand how synchronization, wait(), notify(), etc. work.