Tag: 承诺

即使只有一个线程在线程池中,并发会发生并发吗?

我正在使用Rails 5和Ruby 2.4。 我怎么能弄明白,或者你能看出下面的内容,是否有多个线程在同一时间运行? pool = Concurrent::FixedThreadPool.new(1) promises = links.map do |link| Concurrent::Promise.execute(executor: pool) do result = process_link(link) if result if result.kind_of?(Array) result.each do |my_obj| my_obj.update_attributes({ :a => a }) records_processed = records_processed + my_obj.matches.count end else records_processed = records_processed + result.matches.count result.update_attributes({ :a => a }) end end end end promises.map(&:wait).map(&:value!) 由于我已将我的池设置为“1”,我的假设是没有任何内容同时运行,但我一直收到此错误… Error during […]