2 ms·
>I think Haskell's concurrency must be very different from the types I'm familiar with. It's very different from most concurrency systems. It's a very, very li
by wyager 12y ago
>I think Haskell's concurrency must be very different from the types I'm familiar with.
It's very different from most concurrency systems. It's a very, very lightweight cooperative green thread system. We're kind of dealing with pathological edge cases here. We're forking to do exceptionally simple, fast things (you shouldn't do that) and we're trying to sleep by wasting CPU cycles (you shouldn't do that).
For example, this works fine:
import Control.Concurrent
main = do
forkIO (putStrLn "thing1")
forkIO (putStrLn "thing2")
threadDelay 1000
threadDelay doesn't hog CPU cycles, so the other threads are able to run.
- millstone 12y agoThank you for the explanation. Your code works for me too.