tailstate.nut 359 B

12345678910111213141516171819202122232425
  1. function state1()
  2. {
  3. ::suspend("state1");
  4. return state2();
  5. }
  6. function state2()
  7. {
  8. ::suspend("state2");
  9. return state3();
  10. }
  11. function state3()
  12. {
  13. ::suspend("state3");
  14. return state1();
  15. }
  16. local statethread = ::newthread(state1)
  17. ::print(statethread.call()+"\n");
  18. for(local i = 0; i < 10000; i++)
  19. ::print(statethread.wakeup()+"\n");