threads_04.gm 373 B

1234567891011121314151617
  1. global thread_func = function( a_name, a_count )
  2. {
  3. print( "["+a_name+"] Starting..." );
  4. for (i = 0; i < a_count; i = i + 1)
  5. {
  6. print( "["+a_name+"] iteration: " + i );
  7. yield();
  8. };
  9. print( "["+a_name+"] Finishing..." );
  10. };
  11. print( "[0] Ready to execute..." );
  12. thread( thread_func, 1, 100 );
  13. thread( thread_func, 2, 100 );
  14. sleep(1);
  15. print( "[0] Thread created..." );