Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

[TRIVIAL] the thread becomes dead after we get the value. also we can pass a timeout value to Thread#join and try to join afterwards

View [TRIVIAL] thread_join_and_status.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
t = Thread.new { sleep 5; puts 1 }
puts "status: #{t.status} on #{t.inspect}"
t.join(1)
puts "status: #{t.status} on #{t.inspect}"
t.join(1)
puts "status: #{t.status} on #{t.inspect}"
t.join(1)
puts "status: #{t.status} on #{t.inspect}"
t.join(1)
puts "status: #{t.status} on #{t.inspect}"
t.join(1)
puts "status: #{t.status} on #{t.inspect}"
t.join(1)
puts "status: #{t.status} on #{t.inspect}"
t.join(1)
puts "status: #{t.status} on #{t.inspect}"
t.join(1)
puts "status: #{t.status} on #{t.inspect}"
 
__END__
 
status: sleep on #<Thread:0x1d0ae48 sleep>
status: sleep on #<Thread:0x1d0ae48 sleep>
status: sleep on #<Thread:0x1d0ae48 sleep>
status: sleep on #<Thread:0x1d0ae48 sleep>
status: sleep on #<Thread:0x1d0ae48 sleep>
1
status: false on #<Thread:0x1d0ae48 dead>
status: false on #<Thread:0x1d0ae48 dead>
status: false on #<Thread:0x1d0ae48 dead>
status: false on #<Thread:0x1d0ae48 dead>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.