Skip to content

Instantly share code, notes, and snippets.

@freakflames29
Created June 28, 2021 12:49
Show Gist options
  • Save freakflames29/a5bf1191da8e82c84bf0468057cef533 to your computer and use it in GitHub Desktop.
Save freakflames29/a5bf1191da8e82c84bf0468057cef533 to your computer and use it in GitHub Desktop.
Thread in ruby
# t=Thread.new{puts "okj"}
b=Thread.new{puts "lvoe"}
# threa=[]
# 5.times do
# threa<<Thread.new{puts "mang0"};
# sleep(2)
# end
# threa.each(&:join)
# puts "Hllp"
#thread error
# Thread.abort_on_exception=true
# begin
# t=Thread.new {raise "hell"}
# rescue RuntimeError
# puts "yeah gotcha"
# end
# t.join
# puts "done"
# Thread pool
pages=%w(index contact)
pages.each{|x| t=Thread.new{x}}
t.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment