@@ -0,0 +1,22 @@
1+import Control.Concurrent (threadDelay, myThreadId)
2+import Control.Monad.IO.Class (liftIO)
3+import System.Random (randomIO)
4+import System.IO
5+
6+import Duct
7+
8+main = waitAsync $ threads 3 $ do
9+ liftIO $ hSetBuffering stdout LineBuffering
10+ mainThread <- liftIO myThreadId
11+ liftIO $ putStrLn $ "Main thread: " ++ show mainThread
12+ x <- sample (randomIO :: IO Int) 1000000
13+ evThread <- liftIO myThreadId
14+ liftIO $ putStrLn $ "X Event thread: " ++ show evThread
15+ liftIO $ putStrLn $ "x = " ++ (show x)
16+
17+ y <- sample (randomIO :: IO Int) 1000000
18+
19+ -- liftIO $ threadDelay 10000000
20+ evThread <- liftIO myThreadId
21+ liftIO $ putStrLn $ "Y Event thread: " ++ show evThread
22+ liftIO $ putStrLn $ "y = " ++ (show y)