System is silently coming out in error with thread.join

There are two rb files:

run_work.rb

···

----------
#some code here
children=[]
str="ruby work.rb"
children<<Thread.new
  system(str)
end
children.each do |c|
  c.join
end
puts 'third'
#some code here

work.rb
------
children=[]
children<<Thread.new
  #some code here
end
puts 'first'
children.each do |c|
  c.join ############## 'alpha'
  puts 'DONE!'
end
puts 'second'

==============================================
If I run run_work.rb, I see output as:
first
third

Where did 'second go'?
So On rubymines I kept one breakpoint at 'alpha'. It doesnt come out of
that join statement and so never print 'DONE!', so again I re-run and
when the control is at alpha (alpha statement is yet to be executed), I
entered c.join in 'watches'-list of debug on rubymines:
it gives:
Couldn't evaluate: t.joinUnable to read information in the specified
timeout[10s].

--
Posted via http://www.ruby-forum.com/.

I'd say this is your problem:

$ ruby -e Thread.new
-e:1:in `initialize': must be called with a block (ThreadError)
        from -e:1:in `new'
        from -e:1:in `<main>'

Cheers

robert

···

On Mon, Dec 3, 2012 at 3:18 PM, Prog Rammer <lists@ruby-forum.com> wrote:

There are two rb files:

run_work.rb
----------
#some code here
children=
str="ruby work.rb"
children<<Thread.new
  system(str)
end
children.each do |c|
  c.join
end
puts 'third'
#some code here

work.rb
------
children=
children<<Thread.new
  #some code here
end
puts 'first'
children.each do |c|
  c.join ############## 'alpha'
  puts 'DONE!'
end
puts 'second'

==============================================
If I run run_work.rb, I see output as:
first
third

Where did 'second go'?

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Prog Rammer wrote in post #1087634:

Where did 'second go'?

Once you get your syntax problems corrected, try giving every variable a
unique name and see what happens. Then google 'threads' and 'processes'
and try to figure out the most important difference between the two.

···

--
Posted via http://www.ruby-forum.com/\.

$ ruby -e Thread.new
-e:1:in `initialize': must be called with a block (ThreadError)
        from -e:1:in `new'
        from -e:1:in `<main>'

Cheers

robert

I dont get a fix yet.. :frowning:

···

--
Posted via http://www.ruby-forum.com/\.