As a method without having to worry about threads you could also use:

require 'timeout'

messages = ["What are you waiting for?", "I don't have all day.", "When
I said 'take your time', I didn't mean this long!", "Hurry up and enter
a value!"]

s = nil
until s
  begin
    Timeout::timeout(5) do
      puts "Enter a value: "
      s = gets
    end
  rescue Timeout::Error
    puts messages[rand(messages.length).to_i]
  end
end