#!/usr/bin/env ruby

require 'thread'

def beat_thread
  $stop = false
  bt = Thread.new do
    loop do
      print "."
      sleep 0.25
      break if $stop
    end
  end
  yield
  $stop = true
  bt.join
end

puts "File exist?:"
beat_thread { File.exist? 'blocking_dir/file54' }

puts

puts "File read:"
beat_thread { File.read 'blocking_dir/file54' }
