in reply to Re^2: Printing to STDERR causes deadlocks.
in thread Printing to STDERR causes deadlocks.
I'm familiar with C's pthreads so YMMV, but it looks like you are setting $$doneRef = 1 outside of the lock, after the signal is sent, so perhaps the signal is being received before the thread has a chance to set $$doneRef. Generally you'll want to set/check shared variables only when you have a lock held.