Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
import Control.Concurrent
|
||||
import Control.Monad
|
||||
import Data.Maybe
|
||||
import System.IO
|
||||
|
||||
main = do
|
||||
c <- newEmptyMVar
|
||||
hSetBuffering stdin NoBuffering
|
||||
forkIO $ do
|
||||
a <- getChar
|
||||
putMVar c a
|
||||
putStrLn $ "\nChar '" ++ [a] ++
|
||||
"' read and stored in MVar"
|
||||
wait c
|
||||
where wait c = do
|
||||
a <- tryTakeMVar c
|
||||
if isJust a then return ()
|
||||
else putStrLn "Awaiting char.." >>
|
||||
threadDelay 500000 >> wait c
|
||||
Loading…
Add table
Add a link
Reference in a new issue