Add mutex to the Emitter object to prevent race conditions.