Concurrency
concurrencyicon.icon
Overview
Communication methods
Shared memory
All threads can access the same memory and communicate by modifying and inspecting mutable variables.
Very convenient (if large amounts of data are shared).
Potentially risky (race conditions, ...).
Message passing
Communication via messages sent between threads.
More overhead if large amounts of data are shared.
Less risky.
Well-known libraries
Control.Concurrent
forkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId
Executes the second argument once the thread is about to finish, whether normally or via an exception.
Example codes
Useful link
Useful link(Japanese)