Ruby: How to check a threads status when it has not been initialized yet?

Viewed 18

I have a program that has the option to start two different threads. There are some functions that check the status of these threads to stop them, check if they are deployed, etc....

Is there a way to check the status of a thread variable that wont crash the program if the thread being checked hasn't been started yet?

$thr = []
$time
$spread

def threads() 
        puts "#{(Threads.list.length) - 1} loops running"
        puts "Is time thread alive?       #{$time.alive?}"
        puts "Is spread thread alive?     #{$spread.alive?}"
end
0 Answers
Related