Thread synchronization

Hi guys,
I've got issue with this example part of code:
stationStatsTr = Thread.new do
  while(true)
    puts "stationStatsTr\n"
    sleep 1
  end
end

rulesTr = Thread.new do
  while(true)
    #puts stationStatsTr.status
    sleep 1
    stationStatsTr.stop() if stationStatsTr.status == "run"
    puts "rulesTr\n"
    sleep 1
  end
end

stationStatsTr.join(10)
rulesTr.join(10)

#the output from this is as follows
stationStatsTr
stationStatsTr
stationStatsTr
stationStatsTr
stationStatsTr
stationStatsTr
stationStatsTr
stationStatsTr
stationStatsTr
stationStatsTr
C:/Documents and
Settings/PROXIMETRY/Desktop/Autotests/Fake_DDL/testing.rb:12: undefined
method `stop' for #<Thread:0x2bb79dc dead> (NoMethodError)
        from C:/Documents and
Settings/PROXIMETRY/Desktop/Autotests/Fake_DDL/testing.rb:22:in `join'
        from C:/Documents and
Settings/PROXIMETRY/Desktop/Autotests/Fake_DDL/testing.rb:22

···

#####################################################################
REPLACING stationStatsTr.stop() by stationStatsTr.kill works as expected
(stationStats is killed and rulesTr is running). But stop() method
cannot stop stationStatsTr. Moreover rulesTr doesn't run (as you can see
in output) and error occured at the end of script (after set 10 secs in
join).
What is going on with this. The idea of the part of code is that only
one of the threads should run simultaneously. The rulesTr should be able
to stop and start staionStatsTr.

Any help will be helpful.
Thanks in advance,
MT
--
Posted via http://www.ruby-forum.com/.