快速同步循环

时间:2015-02-27 13:58:45

标签: ios swift thread-safety

Digita il testo o l'indirizzo di un sito web oppure traduci un documento。 我很快就是新手。我无法同步两个周期的工作,然后显示结果。

例如:

// Step1: do the first cycle.
for value0 in list0{
    doStuff()
}

// Step1: do the second cycle.
for value1 in list1{
    doStuff()
}

// Show result.

showResult()

我试过这样做:

let lockQueue = dispatch_queue_create("com.test.LockQueue", nil)
dispatch_sync(lockQueue) {
    // Step1: do the first cycle.
    for value0 in list0{
       doStuff()
    }

    // Step1: do the second cycle.
    for value1 in list1 {
       doStuff()
    }

    // Show result.
}
showResult()

它可以工作和编译,但不会同步两个代码的工作。实际上显示结果不完整。

0 个答案:

没有答案