# ThreadLimiter 0.1.0

**URL:** <https://www.ruby-forum.com/t/threadlimiter-0-1-0/142913>\
**Category:** Ruby\
**Created:** [July 13, 2008, 12:22pm UTC](https://www.ruby-forum.com/t/threadlimiter-0-1-0/142913 "2008-07-13T12:22:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikveen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/59ef9b/32.png) [@erikveen](https://www.ruby-forum.com/u/erikveen)\
**Post date:** [July 13, 2008, 12:22pm UTC](https://www.ruby-forum.com/t/threadlimiter-0-1-0/142913/1 "2008-07-13T12:22:05Z")

</div>

ThreadLimiter 0.1.0 is released.

RDoc: [threadlimiter (0.2.1)](http://www.erikveen.dds.nl/threadlimiter/doc/index.html)  
Download: [http://rubyforge.org/projects/threadlimiter/index.html](http://rubyforge.org/projects/threadlimiter/index.html)

gegroet,  
Erik V. - [http://www.erikveen.dds.nl/](http://www.erikveen.dds.nl/)

* * *

ThreadLimiter forks threads like Thread.fork(), but limits the  
number of concurrently running threads.

ThreadLimiter isn’t a thread pool. Each fork really starts a  
new thread.

Example: Get the titles of a large collections of URL’s.

The traditional way, using Thread directly:

urls = […] # A lot of URL’s. Maybe  
even thousends.

titles =  
urls.collect do |url|  
Thread.fork do  
# … get the title of the url…  
end  
end.collect do |thread|  
thread.value  
end

With ThreadLimiter#fork():

thread\_limiter = ThreadLimiter.new(10) # Max. 10 concurrently  
running threads.  
urls = […] # A lot of URL’s. Maybe  
even thousends.

titles =  
urls.collect do |url|  
thread\_limiter.fork do  
# … get the title of the url…  
end  
end.collect do |thread|  
thread.value  
end

With Enumerable#threaded\_collect():

urls = […] # A lot of URL’s. Maybe  
even thousends.

titles =  
urls.threaded\_collect(10) do |url| # Max. 10 concurrently  
running threads.  
# … get the title of the url…  
end
