Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between Runloop and thread?

  • What is run loops actually ?
  • what a difference from thread ?
  • Where we must need to use run loop and where aren't we use ?
like image 379
virus Avatar asked Sep 18 '25 18:09

virus


1 Answers

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.

like image 126
9dan Avatar answered Sep 23 '25 09:09

9dan