[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

thread closing?

Tim Mcd

8/24/2008 2:45:00 AM

@t1 = Thread.new do
b = false
until b == true
sleep 10
puts "you are getting cold!"
end
end

So, that gets called when a play enters a 'cold' room. I want to set in
the 'leave' event:

@t1.close

or something to that effect, but i get errors when trying to call
@t1.exit... Any thoughts?
--
Posted via http://www.ruby-....

1 Answer

Roger Pack

8/25/2008 1:13:00 PM

0

Tim Mcd wrote:
> @t1 = Thread.new do
> b = false
> until b == true
> sleep 10
> puts "you are getting cold!"
> end
> end
>
> So, that gets called when a play enters a 'cold' room. I want to set in
> the 'leave' event:
>
> @t1.close
>
> or something to that effect, but i get errors when trying to call
> @t1.exit... Any thoughts?

You can call @t1.raise or @t1.kill, however those methods are pretty
scary. I'd do something like polling:
b = false
@t1 = Thread.new { sleep 10 until b == true}
and set b to true elsewhere in the code.
-=R
--
Posted via http://www.ruby-....