4
  • What is run loops actually ?
  • what a difference from thread ?
  • Where we must need to use run loop and where aren't we use ?
virus
  • 1,203
  • 13
  • 21
  • Have a look here: http://stackoverflow.com/questions/2789357/clarification-on-threads-and-run-loops-in-cocoa and here: http://blog.shinetech.com/2009/06/02/run-loops-vs-threads-in-cocoa/ – sbarow Aug 26 '14 at 07:48

1 Answers1

6

RunLoop is a looping mechanism. It is a kind of infinite loop.

Thread is a conceptual model of code execution(thread). Not directly related with loops or function calls. It denote flow of code. Internally, each thread has separate stack frame.

There exists the main thread (one and only one). By default, the main thread execute the main runloop.

The main runloop primarily handles keyboard and mouse input. Waiting infinitely for input events and calls appropriate event handlers.

One can create another thread and another runloop for background processing of not UI related events such as async socket, etc.

9dan
  • 4,222
  • 2
  • 29
  • 44