         else if activityVisibleCount < Int.max {
             activityVisibleCount += 1
         }
+        
+        lock.unlock()
     }
     
     public func hide() {
+        lock.lock()
+        
         if activityVisibleCount == 1 {
             UIApplication.sharedApplication().networkActivityIndicatorVisible = false
             activityVisibleCount = 0

        else if activityVisibleCount > 0 {
            activityVisibleCount -= 1
        }
    }
}

    }

    public func show() {
        lock.lock()
        
        if activityVisibleCount == 0 {
            UIApplication.sharedApplication().networkActivityIndicatorVisible = true
            activityVisibleCount = 1
