在Ruby中的Thread.new出口后打印一行



基本上,我想知道Thread.new创建的线程何时退出并在其后放置一行。我该怎么做?

您可以使用Thread.join进行阻塞,直到线程终止:

thread = Thread.new  # Obviously called with necessary arguments
thread.join
puts "Thread has terminated"

最新更新