This one mostly works, i.e., the threads seems to interact in a reasonable fashion.  However, there still seems to be a few issues with the signal handler.