                 XCTFail((error as? CustomStringConvertible)?.description ?? "Unknown")
             }
             
-            usleep(1500)
+            usleep(500)
         }
         
         quit = true
         waitForExpectationsWithTimeout(1000, handler: nil)
+    }
+    
+    func testConcurrentAccess() throws {
+        
+        let _ = try? NSFileManager.defaultManager().removeItemAtPath("\(NSTemporaryDirectory())/SQLite.swift Pool Tests.sqlite")
+        let pool = try! ConnectionPool(.URI("\(NSTemporaryDirectory())/SQLite.swift Pool Tests.sqlite"))
+        
+        try! pool.writable.execute("DROP TABLE IF EXISTS test; CREATE TABLE test(value);")
+        try! pool.writable.run("INSERT INTO test(value) VALUES(?)", 0)
+        
+        let q = dispatch_queue_create("Readers/Writers", DISPATCH_QUEUE_CONCURRENT);
+        var finished = false
+        
+        for _ in 0..<5 {
+            
+            dispatch_async(q) {
+                
+                while !finished {
+                    
+                    let val = pool.readable.scalar("SELECT value FROM test")
+                    assert(val != nil, "DB query returned nil result set")
+                    
+                }
+                
+            }
+            
+        }
+        
+        for c in 0..<5000 {
+            
+            try pool.writable.run("INSERT INTO test(value) VALUES(?)", c)
+            
+            usleep(100);
+            
+        }
+        
+        finished = true
+        
+        // Wait for readers to finish
+        dispatch_barrier_sync(q) {
+        }
+        
     }
     
     func testAutoRelease() {

        super.setUp()
    }

    func testConcurrentAccess() {
        
        let _ = try? NSFileManager.defaultManager().removeItemAtPath("\(NSTemporaryDirectory())/SQLite.swift Pool Tests.sqlite")
        let pool = try! ConnectionPool(.URI("\(NSTemporaryDirectory())/SQLite.swift Pool Tests.sqlite"))
        
        let conn = pool.writable
        try! conn.execute("CREATE TABLE IF NOT EXISTS test(id INTEGER PRIMARY KEY, name TEXT)")
        try! conn.execute("DELETE FROM test")
        try! conn.execute("INSERT INTO test(id,name) VALUES(0, 'test0')")
        try! conn.execute("INSERT INTO test(id,name) VALUES(1, 'test1')")

            
        }
        
        for x in 10..<5000 {
            
            let name = "test" + String(x)
            let idx = Int(rand()) % 5
