Komoran implements Cloneable { public void analyzeTextFile(String inputFilename, String outputFilename, int thread) { try { List<String> lines = FileUtil.load2List(inputFilename); BufferedWriter bw = new BufferedWriter( (new OutputStreamWriter(new FileOutputStream(outputFilename), StandardCharsets.UTF_8))); List<Future<KomoranResult>> komoranResultList = new ArrayList<>(); ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(thread); for (String line : lines) { KomoranCallable komoranCallable = new KomoranCallable(this, line); komoranResultList.add(executor.submit(komoranCallable)); } for (Future<KomoranResult> komoranResultFuture : komoranResultList) { KomoranResult komoranResult = komoranResultFuture.get(); bw.write(komoranResult.getPlainText()); bw.newLine(); } bw.close(); executor.shutdown(); } catch (Exception e) { e.printStackTrace(); } } Komoran(String modelPath);  Komoran(DEFAULT_MODEL modelType); void analyzeTextFile(String inputFilename, String outputFilename, int thread); List<KomoranResult> analyze(List<String> sentences, int thread); KomoranResult analyze(String sentence); double scoreDebug(List<String> analyzeResultList, List<String> analyzePosList); List<KomoranResult> analyze(String sentence, int nbest); void setFWDic(String filename); void setUserDic(String userDic);  }
@Test public void textFileAnalyzeTest() { long begin = System.currentTimeMillis(); this.komoran.analyzeTextFile("user_data/wiki.titles", "analyze_result.txt", 4); long end = System.currentTimeMillis(); System.out.println("Elapsed time : " + (end - begin)); }