Skip to content

Instantly share code, notes, and snippets.

@cryks
Created April 26, 2012 14:30
Show Gist options
  • Select an option

  • Save cryks/2499960 to your computer and use it in GitHub Desktop.

Select an option

Save cryks/2499960 to your computer and use it in GitHub Desktop.
#!/usr/bin/env gosh
(use gauche.threads)
(use gauche.partcont)
(define (display-current-thread comment)
(display (format "~a (~a)\n" comment (current-thread))))
(display-current-thread "Start")
(reset
(display-current-thread
(number->string
(+ (shift cont
(let1 t (make-thread
(lambda ()
(display-current-thread "Another Thread Start")
(thread-sleep! 1)
(cont 42))
"Another Thread")
(thread-start! t)))
(shift cont
(let1 t (make-thread
(lambda ()
(display-current-thread "Another Thread II Start")
(thread-sleep! 1)
(cont 128))
"Another Thread II")
(thread-start! t)))))))
(display-current-thread "Waiting...")
(thread-sleep! 5)
(display-current-thread "End")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment