(letrec ((spawn-thread (lambda (it . args) (call/cc (apply it args)))) (main (lambda (label . sequence) (lambda (cc) (let loop ((sequence sequence) (state 0)) (printf "IN MAIN THREAD ~A~N---" state) (if (< state 10) (loop `(,@(cdr sequence) ,(call/cc (car sequence))) (+ state 1))))))) (with-exit (lambda (label data) (lambda (cc) (let loop ((cc cc) (done (lambda () #f)) (state 0)) (cond ((done) (cc data)) (else (printf "IN THREAD ~A TYPE: WITH-EXIT STATE: ~A~N" label state) (loop (call/cc cc) done (+ state 1)))))))) (no-exit (lambda (label data) (lambda (cc) (let loop ((cc cc) (state 0)) (printf "IN THREAD ~A TYPE: NO-EXIT STATE: ~A~N" label state) (loop (call/cc cc) (+ state 1)))))) ;breaks it for some reason? (no-reps (lambda (label data) (lambda (cc) (printf "IN THREAD ~A TYPE: NO-REPS~N" label) (call/cc cc))))) (spawn-thread main 'main (spawn-thread with-exit 1 '()) (spawn-thread no-exit 2 '()) (spawn-thread with-exit 3 '()) ;(spawn-thread no-reps 4 '())) uncomment to see error )) ;you can run this as is, and it works, entering the main thread and then subsequently yielding control to the next thread in the sequence. for some reason the no-reps thread generator breaks it though :/