Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.68 KB | None | 0 0
  1. (use srfi-18)
  2.  
  3. (define do-random
  4.   (lambda ()
  5.     (let ((getalleke (+ 1  (random 5)))
  6.           (thread-sleep! getalleke)
  7.           (display getalleke)
  8.           (newline)
  9.           ))))
  10.  
  11. (define thread1 (make-thread! do-random))
  12. (define thread2 (make-thread! do-random))
  13. (define thread3 (make-thread! do-random))
  14. (define thread4 (make-thread! do-random))
  15. (define thread5 (make-thread! do-random))
  16.  
  17. (thread-start! thread1)
  18. (thread-start! thread2)
  19. (thread-start! thread3)
  20. (thread-start! thread4)
  21. (thread-start! thread5)
  22.  
  23. (thread-join! thread1)
  24. (thread-join! thread2)
  25. (thread-join! thread3)
  26. (thread-join! thread4)
  27. (thread-join! thread5)
  28. (display "finished")
  29.  
  30. (exit)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement