title: Main loop in event-driven programming and alternatives
body: <p>To the best of my knowledge, event-driven programs require a main loop such as </p>
  
  <pre><code>while (1) {
  
  } 
  </code></pre>
  
  <p>I am just curious if this while loop can cost a high CPU usage? Is there any other way to implement event-driven programs without using the main loop?  </p>