PasteRack.org
Paste # 96537
2018-10-07 12:41:44

Fork as a new paste.

Paste viewed 3571 times.


Embed:

  1. #lang racket
  2.  
  3. (define x 0)
  4.  
  5. (define threads
  6.   (for/list ([i (in-range 10)])
  7.     (thread
  8.      (λ ()
  9.        (for ([j (in-range 10)])
  10.          (set! x (begin0 (add1 x)
  11.                          (for ([k (in-range 10000)])
  12.                            (random)))))))))
  13.  
  14. (for-each thread-wait threads)
  15.  
  16. (displayln x)

=>

15