2017-09-23 10:01:46 +02:00
|
|
|
defmodule Concurrent do
|
|
|
|
|
def computing(xs) do
|
|
|
|
|
Enum.each(xs, fn x ->
|
|
|
|
|
spawn(fn ->
|
|
|
|
|
Process.sleep(:rand.uniform(1000))
|
|
|
|
|
IO.puts x
|
|
|
|
|
end)
|
2016-12-05 22:15:40 +01:00
|
|
|
end)
|
2017-09-23 10:01:46 +02:00
|
|
|
Process.sleep(1000)
|
2016-12-05 22:15:40 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2017-09-23 10:01:46 +02:00
|
|
|
Concurrent.computing ["Enjoy", "Rosetta", "Code"]
|