Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   threads and blocking (http://www.velocityreviews.com/forums/t813698-threads-and-blocking.html)

Ara.T.Howard 02-20-2004 06:14 PM

threads and blocking
 


under which conditions will a blocking operation in a thread block the entire
process?

i thought i understood this but was suprised that

~ > ruby -e 'Thread.new{gets}; Thread.new{select nil}; Thread.new{puts 42}'
42

does not seem to block the entire process.

i also was suprised that this worked:

~ > printf "4\n2\n" | ruby -e '[Thread.new{p gets.chop},Thread.new{p
gets.chop}].map{|t| t.join}'
"4"
"2"

i have been in situations before where one thread blocking has blocked my
entire application and remember thinking to myself - "don't do blocking i/o
from threads". but that appears to be too strong of a statement.

can someone concisely enumerate the things to avoid?

regards.

-a
--
================================================== =============================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
================================================== =============================



All times are GMT. The time now is 11:25 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


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