Hello All <br>I was going trough Real World Haskell and it says "If we try to put a value into an <span class="type">MVar</span> that is
already full, our thread is put to sleep until another thread
takes the value out". I wrote a simple code to block main <br><br>import Data.List<br>import Control.Concurrent<br><br>fun m = do<br> putMVar m 10<br> return ()<br><br><br>main = do<br> m <- newEmptyMVar <br>
forkIO $ fun m<br> putMVar m 10<br> return ()<br><br>What I am expecting that main should be blocked at least couple of times but its behaving more deterministically. <br>[mukesh.tiwari@ Programming]$ ghc-7.4.1 -threaded -fforce-recomp Concurrent.hs <br>
[1 of 1] Compiling Main ( Concurrent.hs, Concurrent.o )<br>Linking Concurrent ...<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>
[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>
[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>
[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>[mukesh.tiwari@ Programming]$ ./Concurrent +RTS -N2<br>
[mukesh.tiwari@ Programming]$ <br><br>I am expecting to get thread blocked indefinitely on MVar at least half the time. Could some one please tell me why this deterministic behavior ? <br>Regards <br>Mukesh Tiwari<br><br>