1 -- !!! test threadDelay, Random, and QSemN.
3 -- start a large number (n) of threads each of which will wait for a
4 -- random delay between 0 and m seconds. We use a semaphore to wait
5 -- for all the threads to finish.
11 n = 5000 -- no. of threads
12 m = 3000 -- maximum delay
16 (is :: [Int]) <- sequence (take n (repeat (getStdRandom (randomR (1,m)))))
17 mapM (fork_sleep s) is
20 fork_sleep s i = forkIO (do waitQSemN s 1