threading: Prevent possible division by zero