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

前端 未结 3 820
广开言路
广开言路 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条回答
  •  Happy的楠姐
    2021-02-10 00:29

    It's not clear what you want to do. Stop the thread and resume the same function on a new thread? (That would be pointless—what was wrong with the old thread?) Stop the thread and resume the same function on another existing thread?

    Either way, no, it's not possible, and it's not even a good idea. The correct solution is to split your function in two, then use some or all of the run loop, NSTimer, the performSelector… methods, and NSPort to achieve whatever it is you want to do.

    Your program will work much better without all this dark thread magic going on that you're envisioning.

提交回复
热议问题