Ruby does not allow you to create variable names from strings in the same way that PHP does. In a case such as this you could use an array or a hash instead.
times = 30
n=0
arrays = []
thread = []
while n < times
thread << Thread.new(n) {|x|
arrays[x] = Array.new()
...
}
end
You can also use more rubyish constructs instead of while, such as Fixnum#times.
arrays = []
threads = 30.times.map do |n|
Thread.new do
arrays[x] = Array.new
# ...
end
end
> arrays
#=> [[], [], [], ....]
> threads
#=> [#<Thread:0x007fe3f22a2320 dead>, #<Thread:0x007fe3f22a2208 dead>, ...]