thread closing?

T

Tim Mcd

@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?
 
R

Roger Pack

Tim said:
@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
 

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

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top