             print("Frame #\(self.frameCount)")
         }*/
         self.frameCount++
-        if self.frameCount % 100 != 1 {
+        if self.frameCount < 50 {
+            return
+        }
+        var ok = false
+        objc_sync_enter(self.running)
+        if !self.running {
+            ok = true
+            self.running = true
+        }
+        objc_sync_exit(self.running)
+        if !ok {
             return
         }
 


    var previewLayer: AVCaptureVideoPreviewLayer?
    var frameCount = 0

    var metalDevice: MTLDevice?
    var metalLib: MTLLibrary?

        let label = "\(net!.labels[idx]) - \(prob*100)%"
        let workTime = NSDate().timeIntervalSinceDate(startTime)
        print("net.forward is done within \(workTime) sec")
        objc_sync_enter(self.running)
        self.running = false
        objc_sync_exit(self.running)

        print("GoogLeNet: \(label)")
        dispatch_async(dispatch_get_main_queue(), {
