Trying to work with Threads

Discussion in 'Ruby' started by |MKSM|, Sep 5, 2006.

  1. |MKSM|

    |MKSM| Guest

    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
     
    |MKSM|, Sep 5, 2006
    #1
    1. Advertising

  2. |MKSM|

    Heesob Park Guest

    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/
    for more detail.

    Regards,

    Park Heesob


    --
    Posted via http://www.ruby-forum.com/.
     
    Heesob Park, Sep 5, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Horsley

    Noob can't make threads work

    Steve Horsley, Mar 1, 2005, in forum: Python
    Replies:
    4
    Views:
    311
    Steve Holden
    Mar 1, 2005
  2. yoda
    Replies:
    2
    Views:
    445
    =?utf-8?Q?Bj=C3=B6rn_Lindstr=C3=B6m?=
    Aug 1, 2005
  3. threads without threads

    , Aug 27, 2004, in forum: C Programming
    Replies:
    4
    Views:
    411
    William Ahern
    Aug 27, 2004
  4. Pedro Pinto

    Java Threads - Get running threads

    Pedro Pinto, Apr 8, 2008, in forum: Java
    Replies:
    2
    Views:
    1,454
    Arne Vajhøj
    Apr 9, 2008
  5. Une bévue
    Replies:
    0
    Views:
    156
    Une bévue
    Jun 14, 2006
Loading...

Share This Page