# Blocking ruby threads

**URL:** <https://www.ruby-forum.com/t/blocking-ruby-threads/86656>\
**Category:** Ruby\
**Created:** [February 24, 2007, 4:41am UTC](https://www.ruby-forum.com/t/blocking-ruby-threads/86656 "2007-02-24T04:41:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![snacktime](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7feea3/32.png) [@snacktime](https://www.ruby-forum.com/u/snacktime)\
**Post date:** [February 24, 2007, 4:41am UTC](https://www.ruby-forum.com/t/blocking-ruby-threads/86656/1 "2007-02-24T04:41:35Z")

</div>

I’ve read a lot of bits and pieces in the past but maybe someone can  
help me finalize my thoughts here or correct me where I am wrong.

From my understanding ruby threads will not block unless you are  
calling out to a C extension which blocks, or in specific off the wall  
case like needing to use resolve-replace so dns lookups don’t block.  
I understand it to be this way because the select loop that is used to  
implement the threads will not do IO reads/writes unless there is data  
that is ready.

Am I missing anything here? Are there other edge cases where ruby  
threads would block?

Chris

---

<div class="post-metadata">

**Author:** ![snacktime](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7feea3/32.png) [@snacktime](https://www.ruby-forum.com/u/snacktime)\
**Post date:** [February 24, 2007, 11:01am UTC](https://www.ruby-forum.com/t/blocking-ruby-threads/86656/2 "2007-02-24T11:01:03Z")

</div>

On 24.02.2007 04:41, snacktime wrote:

> I’ve read a lot of bits and pieces in the past but maybe someone can  
> help me finalize my thoughts here or correct me where I am wrong.
> 
> From my understanding ruby threads will not block unless you are  
> calling out to a C extension which blocks, or in specific off the wall  
> case like needing to use resolve-replace so dns lookups don’t block.

That depends on how DNS lookups are implemented in Ruby. If a standard  
library funtion is called then the interpreter might actually block.

> I understand it to be this way because the select loop that is used to  
> implement the threads will not do IO reads/writes unless there is data  
> that is ready.
> 
> Am I missing anything here? Are there other edge cases where ruby  
> threads would block?

Not exactly an edge case but Ruby threads will block when trying to grab  
a mutex or monitor that is hold by another thread.

Kind regards

robert
