W
Wonderdog
If I have require'd a module and call a method within that module from
within a thread, do all the variables within that external module need
to be made thread safe?
test.rb ==>
require 'mod'
threads = []
(1..20).each do
threads << Thread.new( var ) { |var|
# call a function/method within mod
modFunction( var )
}
threads.each {|a| a.join}
mod.rb ==>
def modFunction( myvar )
# do lotsa copmlex stuff with myvar
....
end
===
Does the 'myvar' variable above need to be 'Thread.current[ "myvar" ]'
instead?
Thanks for helping this noob out!
wd
within a thread, do all the variables within that external module need
to be made thread safe?
test.rb ==>
require 'mod'
threads = []
(1..20).each do
threads << Thread.new( var ) { |var|
# call a function/method within mod
modFunction( var )
}
threads.each {|a| a.join}
mod.rb ==>
def modFunction( myvar )
# do lotsa copmlex stuff with myvar
....
end
===
Does the 'myvar' variable above need to be 'Thread.current[ "myvar" ]'
instead?
Thanks for helping this noob out!
wd