 import XCTest
 import CleanroomConcurrency
 
-private var counter = 0             // a global value to protect with a ReadWriteCoordinator
+private var protect = 0             // a global value to protect with a ReadWriteCoordinator
 private var remainingThreads = 0    // used with an NSCondition signal to keep track of our threads
+private var executions = 0          // count the number of times the
 
 private let ShortWaitTimeout        = NSTimeInterval(1.0)
 private let LongWaitTimeout         = NSTimeInterval(100.0)

        override func main()
        {
            let fn = { () -> Void in

                // this also tests re-entrancy
                let gotLock = self.lock.executeWithTimeout(LongWaitTimeout) {
                    XCTAssertTrue(counter == 0)
                    counter++
                    XCTAssertTrue(counter == 1)
                    counter--
                    XCTAssertTrue(counter == 0)
                }
                XCTAssertTrue(gotLock)

            }

            for _ in 0..<TestThreadIterations {

        }
        signal.unlock()

        XCTAssert(protect == 0)
        XCTAssert(executions == NumberOfThreads * TestThreadIterations)
        XCTAssert(remainingThreads == 0)
    }

