David Pfeiffer
1 min readJan 1, 2022

--

Hi, thank you for your response. Just a reminder, this is actually not my solution, it is a solution proposed long ago by a famous mathematician.

It appears that you found a bug in my code! Thank you for sharing it here. I have updated the code sample with the fix as discussed on the GitHub Gist page.

I wrote this code a long time ago (back when I was in college) so I am not that surprised that there was a bug in there. The program seemed to work before the fix, but the bug you found created a race condition which could have caused the program to reach a state of deadlock as discussed in this article.

This is a great example of why concurrent programming can be so challenging. Just because the program works most of the time doesn't mean that it will work every time, as there could be some edge case which is broken but does not get encountered very often.

Thanks for reading, and thanks for sharing this bug!

--

--

David Pfeiffer
David Pfeiffer

Written by David Pfeiffer

I write about science, technology, philosophy, personal growth, education, and life.

Responses (1)