public string[] getOptimizedIndicators(List <string> indicatorsToTry, IndicatorSelector selector, int threads) { ended = false; indicatorToTryIndex = 0; indicatorsToTryCount = indicatorsToTry.Count; Logger.log("Start testing indicators"); List <Thread> ths = new List <Thread>(); for (int i = 0; i < threads; i++) { ths.Add(new Thread(delegate() { optimizeInternally(indicatorsToTry, selector); })); } foreach (Thread t in ths) { t.Start(); } foreach (Thread t in ths) { if (t.IsAlive) { t.Join(); } } return(selector.getResultingCandidates()); }