\r
private static ExecutorService fast = Executors.newFixedThreadPool(2) ;\r
private static ExecutorService slow = Executors.newFixedThreadPool(2);\r
+ private boolean stop = false;\r
\r
public class IntervalDomain implements Iterable<Amount<X>>{\r
\r
\r
public void setDomain(final Iterable<Amount<X>> d) {\r
series.clear();\r
+ stop = true;\r
fill(d, 100);\r
fast.submit(new Thread(){\r
public void run(){\r
- fill(d, 10);\r
+ if ( !stop )\r
+ fill(d, 10);\r
slow.submit(new Thread(){\r
public void run(){\r
- fill(d, 1);\r
+ if ( !stop )\r
+ fill(d, 1);\r
}\r
});\r
}\r
}\r
\r
@SuppressWarnings("unchecked")\r
- private void fill(Iterable<Amount<X>> d, int skip) {\r
+ private synchronized void fill(Iterable<Amount<X>> d, int skip) {\r
+ stop = false;\r
int sz = 0;\r
if (d instanceof Collection) {\r
sz = ((Collection) d).size();\r
try {\r
Amount<X> last = null;\r
for (Amount<X> ax : d) {\r
+ if ( stop ){\r
+ System.out.println("Stopping early " + skip);\r
+ return;\r
+ }\r
last = ax;\r
if (cnt % skip == 0) {\r
Amount<Y> y = (Amount<Y>) f.invoke(source, ax);\r