add a JOIN_THREADS_BEFORE_FORK preprocessor flag to help debug locking problems