简体   繁体   English

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

[英]Print a line after Thread.new exit in Ruby

Basically I would like to know when the thread created by Thread.new exit and puts a line after that. 基本上,我想知道Thread.new创建的线程Thread.new退出并在Thread.new放一行。 How do I do that? 我怎么做?

You can use Thread.join to block until the thread terminates: 您可以使用Thread.join阻塞直到线程终止:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM