def METHOD_NAME(self, create_deadlock):
    NLOCKS = 10
    locks = [self.LockType(str(i)) for i in range(NLOCKS)]
    pairs = [(locks[i], locks[(i+1)%NLOCKS]) for i in range(NLOCKS)]
    if create_deadlock:
        NTHREADS = NLOCKS
    else:
        NTHREADS = NLOCKS - 1
    barrier = threading.Barrier(NTHREADS)
    results = []
    def _acquire(lock):
        """Try to acquire the lock. Return True on success, False on deadlock."""
        try:
            lock.acquire()
        except self.DeadlockError:
            return False
        else:
            return True
    def f():
        a, b = pairs.pop()
        ra = _acquire(a)
        barrier.wait()
        rb = _acquire(b)
        results.append((ra, rb))
        if rb:
            b.release()
        if ra:
            a.release()
    lock_tests.Bunch(f, NTHREADS).wait_for_finished()
    self.assertEqual(len(results), NTHREADS)
    return results