
2 Jan
2011
2 Jan
'11
4:42 p.m.
Unfortunately this code can deadlock. Consider main = do svar <- newEmptySampleVar forkIO $ readSampleVar svar threadDelay 1000000 forkIO $ writeSampleVar svar () threadDelay 1000000 emptySampleVar svar This program deadlocks, but emptySampleVar should return immediately. After writeSampleVar is executed, the SampleVar thinks the val is full, so emptySampleVar tries to empty it, entering a deadlock. Eric