is there a way to pause an NSTHread indefinitely and have it resumed from another thread?

前端 未结 3 813
广开言路
广开言路 2021-02-09 23:58

Seems these are the only methods to put a NSThread to sleep

* sleepForTimeInterval:

* sleepUntilDate:

Would it be bad practice what I am aski

3条回答
  •  太阳男子
    2021-02-10 00:19

    If you really do have tasks that you need to execute on a background thread, yet one task needs for another to be completed before it executes, I'd recommend looking at NSOperation and NSOperationQueue. NSOperation supports setting very complex dependencies, and NSOperationQueue will handle the scheduling and execution of those operations on however many background threads are appropriate, in the right order. Apple's documentation on these is pretty good, and Drew McCormack has a nice article about the topic at MacResearch.

提交回复
热议问题