threads and blocking

A

Ara.T.Howard

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
===============================================================================
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

non-blocking io 2
io/nonblock - blocks w/threads? 6
idiot's guide to druby using ssh tunnels 4
parent of TrueClass, FalseClass 9
pthread 2
signaling another thread 9
narray on windows? 1
pretty exceptions 0

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top