Skip to content

Instantly share code, notes, and snippets.

@akahn
Created October 21, 2015 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akahn/6aa1743452e3adec33e5 to your computer and use it in GitHub Desktop.
Save akahn/6aa1743452e3adec33e5 to your computer and use it in GitHub Desktop.
require 'thread'
t = Thread.current
Thread.new do
puts 'starting server, takes a few seconds'
# return control to main thread
t.wakeup
end
# Switch context to the server thread by sleeping the main thread
Thread.stop
# Program continues here after wakeup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment