I'm trying to optimize an (infinite) computation algorithm.
I have an infinte Sum to calculate ( Summ_{n-> infinity} (....) ) My idea was to create several threads using the Future < > construct, then combine the intermediate results together. My problem hoewer is that I need a certain precision. So I need to constantly calculate the current result while other threads keep calculating.
My question is: Is there some sort of result queue where each finished thread can put its results in, while a main thread can receive those results and then either lets the computation continues or terminate the whole ExecutorService?
Any Help would really be appreciated! Thanks!