blocking_01.gm 353 B

12345678910111213141516171819202122232425
  1. /*
  2. Yield based thread looping - bad!
  3. */
  4. global WakeUp = false;
  5. global thread_1 = function( a_count )
  6. {
  7. while (WakeUp == false)
  8. {
  9. // Snooze
  10. print("zzz");
  11. yield();
  12. }
  13. print("I just woke up, boy was I tired!");
  14. };
  15. // Launch thread
  16. thread( thread_1 );
  17. // Sleep for 1 secs then set the wakeup variable
  18. sleep(1);
  19. WakeUp = true;