How do I build a car's factory pipeline with RemoteChannel?

You should really setup a pipe and stages to process the items in it.
You could try:

using Distributed
addprocs(4)

@everywhere using Printf
@everywhere function stage(prc::String, input::RemoteChannel, output::RemoteChannel)
    while true
        car = take!(input)
        println(@sprintf("%s the %s %s", prc, car[1], car[2]))
        sleep(2rand())
        println(@sprintf("finished %s", prc))
        put!(output, car)
    end
end

pipe = [RemoteChannel(()->Channel(1)) for _ in 1:4]
factory = ["cleaning", "painting", "paying"]
for i in 2:4
    @spawnat i stage(factory[i-1], pipe[i-1], pipe[i])
end

put!(pipe[1], ("red", "Ferrari"))

The stage function runs in a loop, taking a car from the input channel, working on it and putting it into the output channel.

Then you setup a pipe, the stages of your factory and spawn your stage function to the workers.

When you put the red Ferrari into the pipe, you get:

From worker 2:    cleaning the red Ferrari
From worker 2:    finished cleaning
From worker 3:    painting the red Ferrari
From worker 3:    finished painting
From worker 4:    paying the red Ferrari
From worker 4:    finished paying

Try to put in other cars. Nice business, isn’t it? :slightly_smiling_face: