Skip to content

Instantly share code, notes, and snippets.

@kirqe
Created November 10, 2014 16:49
Show Gist options
  • Save kirqe/0fd545d3c5773d177edb to your computer and use it in GitHub Desktop.
Save kirqe/0fd545d3c5773d177edb to your computer and use it in GitHub Desktop.
file-writing_thread
t = Thread.new do
tx=File.new("text.txt", "w+")
(0..2).each do |n|
begin
File.open("part#{n}.txt") do |f|
tx.write(f.readline)
end
rescue Errno::ENOENT
puts "error #{n}"
end
end
tx.close
end
t.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment