Created
April 26, 2012 14:30
-
-
Save cryks/2499960 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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