From: Bertram Scharpf Date: 2009-09-07T20:56:27+09:00 Subject: Re: Executing system commands in threads under Ruby 1.8.6 Hi, Am Montag, 07. Sep 2009, 20:06:32 +0900 schrieb Eleanor McHugh: > On 7 Sep 2009, at 09:55, vhaerun vh wrote: >> Here's a link to the question I asked on SO: >> >> http://stackoverflow.com/questions/1383470/why-is-this-running-like-it-isnt-threaded >> >> I'm executing the calls using backticks. > > Backticks are blocking calls which return the entirety of their stdout as a > single string on completion of the subprocess. I cannot open the above link. So I rewrite Joel's code snippet using backticks: t = Thread.new { puts `echo foo; sleep 1; echo bar` } puts `echo baz; sleep 1; echo quux` t.join Stricly spoken it's not blocking. The "baz" is written to its pipe before "bar". But it is stored until "quux" is echoed and puts is asked to write it out. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de