Use Livebook to open this notebook and explore new ideas.
It is easy to get started, on your machine or the cloud.
# The basics of processes in Elixir
## Examples
All you have to do is to open a [Livebook](https://livebook.dev/) server and import this notebook.
```elixir
spawn(fn -> 3 end)
```
```elixir
pid = spawn(fn -> 3 end)
```
```elixir
Process.alive?(pid)
```
```elixir
pid = spawn(fn -> IO.puts("Adolfo") end)
```
```elixir
Process.alive?(pid)
```
```elixir
Process.sleep(10000)
```
```elixir
pid =
spawn(fn ->
IO.puts("Starting")
Process.sleep(10000)
IO.puts("The end")
end)
```
```elixir
# click evaluate while the process is sleeping
Process.alive?(pid)
```
```elixir
defmodule Example do
def listen do
receive do
{:ok, "hello"} -> IO.puts("World")
_ -> listen()
end
end
end
```
```elixir
pid = spawn(Example, :listen, [])
```
```elixir
Process.alive?(pid)
```
```elixir
send(pid, :hi)
```
```elixir
send(pid, {:ok, "hello"})
```
See source