Is it okay not to call Thread # join?

Can I call Thread#join? In this case, I don’t care if the thread explodes - I just want Unicorn to keep processing.

class MyMiddleware
  def initialize(app)
    @app = app
  end

  def call(env)
    t = Thread.new { sleep 1 }
    t.join # is it ok if I skip this?
    @app.call env
  end
end

Will I get "zombie streams" or something like that?

+5
source share
1 answer

It’s perfectly normal not to name it join- in fact, it is joinoften not required with multithreaded code. You should only call joinif you need to block until a new thread terminates.

You will not get a zombie thread. The new thread will work until completion, and then cleaned up for you.

+7
source

All Articles