나는 꽤 자주 스레드를 사용하고 있는데이 것이 좋습니다 궁금 : 네, 기본적으로레일 3.2.8 - 데이터베이스에 여러 데이터를 저장하면 스레드를 사용해야합니까?
def self.create_all_posts
threads = []
self.fetch_all_posts.each do |e|
if e.present?
threads << Thread.new {
self.create(title: e[:title], url: e[:url])
}
end
end
main = Thread.main # The main thread
current = Thread.current # The current thread
all = Thread.list # All threads still running
all.each { |t| t.join }
end