[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

sleeping Threads

Boris Glawe

1/26/2006 8:37:00 PM

Hi,

I'd like to start thousands of threads, each sleeping a random time and printing
a string to the terminal.

How do you stop a thread for a certain time without stopping the whole process?

1000.times{ |i|
Thread.new{
sleep(rand(10)) # this method does not only stop the thread but the whole
thread!!
puts ("hello world says #{i.to_s}")
}
}

thanks and greets

Boris
5 Answers

Boris Glawe

1/26/2006 8:39:00 PM

0

This is of course wrong:
>
> 1000.times{ |i|
> Thread.new{
> sleep(rand(10)) # this method does not only stop the thread but
> the whole thread!!
> puts ("hello world says #{i.to_s}")
> }
> }
>


it must be



1000.times{ |i|
Thread.new(i){ |x|
sleep(rand(10))
puts ("hello world says #{x.to_s}")
}
}


greets Boris

The Peeler

7/4/2013 10:22:00 AM

0

On Wed, 03 Jul 2013 22:38:05 -0700, The Rectum, the resident psychopath of
sci and scj, FAKING his time zone again and IMPERSONATING his master, The
Peeler, wrote:

>>
>> You know who I mean!
>>
>> LOL


So, you KNOW it's YOU who I meant, you hilarious fucked up psycho and
punching bag! LOL!!!

--
Retarded, anal, subnormal and extremely proud of it: our resident
psychopath, The Retard (aka "The Rectum").

The Peeler

7/4/2013 4:58:00 PM

0

On Thu, 04 Jul 2013 06:04:56 -0700, The Rectum, the resident psychopath of
sci and scj, FAKING his time zone again and IMPERSONATING his master, The
Peeler, wrote:

>> >> You know who I mean!
>> >>
>> >> LOL
>>
>>
>> So, you KNOW it's YOU who I meant, you hilarious fucked up psycho and
>> punching bag! LOL!!!
>
> Seems innit The Grik anus! LOL111111

Yes, you definitely know that it's YOU who is my punching bag, poor idiot!
LOL

--
bozo about "The Rectum":
"you're so fucked up you give even nazis a bad name"
MID: <ce44f190-f534-4091-9cb3-758e202d9849@m9g2000pby.googlegroups.com>

The Peeler

7/5/2013 4:09:00 PM

0

On Thu, 4 Jul 2013 18:57:46 +0200, The Peeler
<finishingoff@themoronicRevd.invalid> wrote:


>>> So, I KNOW it's ME who you meant, a hilarious greeked up Grik psycho and
>>> greeking bag! LOL!!!
>>
>> Seems innit The Grik anus! LOL111111
>
>Yes, I definitely know that it's ME who is your Grik greeking bag, and a poor idiot!
>LOL

GOOD that, you know anus! LOL

The Peeler

7/5/2013 4:55:00 PM

0

On Fri, 05 Jul 2013 09:09:09 -0700, The Rectum, the resident psychopath of
sci and scj, FAKING his time zone again and IMPERSONATING his master, The
Peeler, wrote:

>> >> So, you KNOW it's YOU who I meant, you hilarious fucked up psycho and
>> >> punching bag! LOL!!!
>> >
>> > Seems innit The Grik anus! LOL111111
>>
>> Yes, you definitely know that it's YOU who is my punching bag, poor idiot!
>> LOL
>
> GOOD that, you know anus! LOL

I've known it all the time that you are my favourite punching bag, you
stupid oaf! LOL

--
bozo about "The Rectum":
"you're so fucked up you give even nazis a bad name"
MID: <ce44f190-f534-4091-9cb3-758e202d9849@m9g2000pby.googlegroups.com>