Threaded application in elixir language

Elixir language has no static/compile-time type checking like F#,Scala;ADA.
Exilir language is used in telecom applications , by discord , by pinterest.
It is ideal for threaded applications
Ok , let's start.
Run:
Code:
mix new test
cd test

In the directory lib put the file Main2.Ex :
Code:
defmodule Main3 do

def startme do
    # Run a long-running computation concurrently
    task = Task.async(fn ->
        # Simulate work
        :timer.sleep(1000)
        42
    end)

    # Do other things here...
    IO.puts("Main process is free to work!")
    # Retrieve the result (blocks until the task finishes)
    result = Task.await(task)
    IO.puts("The answer is #{result}")
end

end

Run:
Code:
mix compile
mix run -e "Main3.startme()"

Et voila.
 
Back
Top