Skip to content

Instantly share code, notes, and snippets.

@wedtm
Created March 4, 2012 07:59
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 wedtm/1971174 to your computer and use it in GitHub Desktop.
Save wedtm/1971174 to your computer and use it in GitHub Desktop.
MAX_THREADS = 30
@current_threads = 0
while (true)
if (@current_threads >= MAX_THREADS)
sleep 1
next
end
Thread.new do
@current_threads = @current_threads + 1
... code
@current_threads = @current_threads - 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment