Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Difference between "sleep()" and "Thread.stop"?

Reply
Thread Tools

Difference between "sleep()" and "Thread.stop"?

 
 
Iñaki Baz Castillo
Guest
Posts: n/a
 
      09-10-2008
SGksIGlzIHRoZXJlIGFueSBkaWZmZXJlbmNlIGJldHdlZW4gZG 9pbmc6CgogIHNsZWVwCgphbmQ6
CgogIFRocmVhZC5zdG9wCgo/CgpJbiBib3RoIGNhc2VzIHRoZSBjdXJyZW50IHRocmVhZCBpcy Bp
biAic2xlZXAiIHN0YXRlLgoKQWxzbywgd2h5IHRoZXJlIGlzIG 5vIHdheSB0byBzdG9wL3BhdXNl
L3NsZWVwIGEgdGhyZWFkIGRpZmZlcmVudCBvZiB0aGUgY3Vycm VudD8KSSBtZWFuIHNvbWV0aGlu
ZyBhczoKCiAgdDEgPSBUaHJlYWQuY3VycmVudAogIFRocmVhZC 5uZXcgeyB0MS5zbGVlcCB9ICA8
LS0tIFRoaXMgZG9lc24ndCBleGlzdCAobmVpdGhlciAjc3RvcC BvciAjcGF1c2UpCgoKVGhhbmtz
IGEgbG90LgoKCi0tIApJw7Fha2kgQmF6IENhc3RpbGxvCjxpYm NAYWxpYXgubmV0Pgo=

 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      09-10-2008
2008/9/10 I=F1aki Baz Castillo <>:
> Hi, is there any difference between doing:
>
> sleep
>
> and:
>
> Thread.stop
>


#sleep resumes automatically after a given time, #stop does not.

> In both cases the current thread is in "sleep" state.
>
> Also, why there is no way to stop/pause/sleep a thread different of the c=

urrent?
> I mean something as:
>
> t1 =3D Thread.current
> Thread.new { t1.sleep } <--- This doesn't exist (neither #stop or #paus=

e)

Why should it? With threads you use other mechanisms to control
execution, e.g. a blocking queue, synchronizing on a mutex etc.

Cheers

robert

--=20
use.inject do |as, often| as.you_can - without end

 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      09-10-2008
2008/9/10 I=F1aki Baz Castillo <>:
> 2008/9/10, Robert Klemme <>:
>> 2008/9/10 I=F1aki Baz Castillo <>:
>>
>> > Hi, is there any difference between doing:
>> >
>> > sleep
>> >
>> > and:
>> >
>> > Thread.stop

>>
>> #sleep resumes automatically after a given time, #stop does not.

>
> Object#sleep doesn't resume if there is not parameter:
> sleep # This sleeps forever


I wasn't aware of that. Learn something new every day. Thanks!

> So, which difference exists between Object#sleep (with no parameter)
> and Thread#stop ?


Well, #stop does not accept a time parameter, does it?

Cheers

robert

--=20
use.inject do |as, often| as.you_can - without end

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 7.17 What's the difference between dynamic and lexical (static) scoping? Between local() and my()? PerlFAQ Server Perl Misc 0 04-15-2011 04:00 AM
FAQ 7.17 What's the difference between dynamic and lexical (static) scoping? Between local() and my()? PerlFAQ Server Perl Misc 0 01-06-2011 05:00 PM
difference between between these "char"s arnuld C++ 33 03-05-2007 03:11 PM
Difference between bin and obj directories and difference between project references and dll references jakk ASP .Net 4 03-22-2005 09:23 PM
Exact difference between 'const char *' and 'char *', also diff between 'const' and 'static' Santa C Programming 1 07-17-2003 02:10 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57