summaryrefslogtreecommitdiff
path: root/testsuite/tests/concurrent/should_run/readMVar1.hs
blob: 7038cad348d399489fb47becf4dae3952e6e4bdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Main where

import Control.Concurrent

main = do
    let i = 1000000
    m <- newMVar (0 :: Int)
    let readloop 0 = return ()
        readloop i = do
            readMVar m
            readloop (i-1)
        writeloop 0 = return ()
        writeloop i = do
            readMVar m
            writeloop (i-1)
    forkIO $ readloop i
    writeloop i