我想创建两个类,如下所示:
class User < ActiveRecord::Base
def self.some_method(array = ['name1', 'name2']) # a string array
...
end
end
class ThreadCreator
builder.c '
void function do_with_threads(how_many, **array)
create how_many threads, and pass each one slice of **array, example a = array[0], a = array[1] etc
each thread calls: User.some_method(a)
end
'
end
e = ThreadCreator.new
e.do_with_threads(3, [
['name1'],
['name2', 'name3'],
['name4']
])
现在,我如何实现do_with_threads方法调用的细节,以便创建3个线程,每个线程调用User.some_method,第一个线程使用['name1']调用它,第二个线程调用['name2] ','name3']和['name3']的第三个线程,所以代码User.some_method(array = [])是用上面描述的线程执行的?