// marginalise over all corpus files using threads public synchronized void count() { Helper.report("[ContextCounter] Counting over all corpus files..."); File corpusFolder = new File(DepNeighbourhoodSpace.getProjectFolder(), Corpus.getFolderName()); String[] corpusFilenames = corpusFolder.list(); Arrays.sort(corpusFilenames); // run each dep marginaliser thread for (String corpusFilename : corpusFilenames) { DepContextCounterThread ccThread = new DepContextCounterThread( this, corpusFilename, new File(corpusFolder, corpusFilename), amountOfSentences); threads.add(ccThread); (new Thread(ccThread)).start(); } // wait for all threads to finish try { while (!threads.isEmpty()) { wait(); } } catch (InterruptedException e) { } Helper.report("[ContextCounter] ...Finished counting over all corpus files..."); }