         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)
+                    executions++
+
+                    XCTAssertTrue(protect == 0)
+                    protect++
+                    XCTAssertTrue(protect == 1)
+                    protect--
+                    XCTAssertTrue(protect == 0)
                 }
                 XCTAssertTrue(gotLock)
-
             }
 
             for _ in 0..<TestThreadIterations {

//
//                // this also tests re-entrancy
//                let gotLock = self.lock.executeWithTimeout(LongWaitTimeout) {
//                    XCTAssertTrue(counter == 0)
//                    counter++
//                    XCTAssertTrue(counter == 1)
//                    counter--
//                    XCTAssertTrue(counter == 0)
//
//                    ExceptionTrap.throwExceptionWithName("try to break the locks")
//                }

import XCTest
import CleanroomConcurrency

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)
