calling a function on a background thread ios-what happens to the nested function calls

[亡魂溺海] 提交于 2019-12-11 23:42:50

问题


In my main code(in order to show UIActivityIndicatorView) I'm calling a function, foo() on a background thread. What happens to the functions called by foo() in turn? Will those functions also be called and executed in the same background thread?


回答1:


Yes, it will also be called in that same background thread.

It's actually pretty easy: everything you call will be run in the same thread as the caller, unless you explicitly use methods to create a new thread and run a method there or cause a method to be run in another thread (e.g. performSelectorOnMainThread:withObject:waitUntilDone:). But from those methods on it's the same again: they will be run in the very same thread as their callers.



来源:https://stackoverflow.com/questions/5151521/calling-a-function-on-a-background-thread-ios-what-happens-to-the-nested-functio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!