# Trying to work with Threads

**URL:** <https://www.ruby-forum.com/t/trying-to-work-with-threads/67545>\
**Category:** Ruby\
**Created:** [September 5, 2006, 4:26am UTC](https://www.ruby-forum.com/t/trying-to-work-with-threads/67545 "2006-09-05T04:26:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSMKSM](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@SSMKSM](https://www.ruby-forum.com/u/SSMKSM)\
**Post date:** [September 5, 2006, 4:26am UTC](https://www.ruby-forum.com/t/trying-to-work-with-threads/67545/1 "2006-09-05T04:26:57Z")

</div>

Hello,

I was doing a quick test with Threads in my Win32 box and something  
strange occured. The point here is to input text without interrupting  
the counter. I plan to use a similar method to display text incoming  
from a server while being able to send messages and such. A couple of  
people told me that it works ok on \*nix, but I can’t get it to work  
here.

The code:

t1 = Thread.new {  
x=0  
loop do  
puts x  
x+=1  
sleep(1)  
end  
}

t2 = Thread.new {  
loop do  
y = gets.chomp  
puts y  
end  
}

t1.join  
t2.join

Regards,

Ricardo Amorim

---

<div class="post-metadata">

**Author:** ![SSMKSM](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bc8723/32.png) [@SSMKSM](https://www.ruby-forum.com/u/SSMKSM)\
**Post date:** [September 5, 2006, 7:08am UTC](https://www.ruby-forum.com/t/trying-to-work-with-threads/67545/2 "2006-09-05T07:08:48Z")

</div>

Hi,

|MKSM| wrote:

> Hello,
> 
> I was doing a quick test with Threads in my Win32 box and something  
> strange occured. The point here is to input text without interrupting  
> the counter. I plan to use a similar method to display text incoming  
> from a server while being able to send messages and such. A couple of  
> people told me that it works ok on \*nix, but I can’t get it to work  
> here.
> 
> The code:
> 
> t1 = Thread.new {  
> x=0  
> loop do  
> puts x  
> x+=1  
> sleep(1)  
> end  
> }
> 
> t2 = Thread.new {  
> loop do  
> y = gets.chomp  
> puts y  
> end  
> }
> 
> t1.join  
> t2.join
> 
> Regards,
> 
> Ricardo Amorim

This is a well-known win32 bug.  
Though I had tried to fix the bug about 3 years ago, it was not  
accepted.  
Refer to  
[http://groups.google.co.kr/group/comp.lang.ruby/tree/browse\_frm/thread/71b7702b046d0a31/](http://groups.google.co.kr/group/comp.lang.ruby/tree/browse_frm/thread/71b7702b046d0a31/)  
for more detail.

Regards,

Park H.
