저는 성경을위한 텍스트 검색 프로그램을 작성 중이며 스레드를 사용하여 작업을 나눠서 실행 시간이 단축되도록하고 싶습니다. 나는 Java 프로그래밍에 익숙하지만 모든 "스레드"에 완전히 익숙합니다. 기본적으로이 프로그램은 성경의 개별 서적을 꺼내 텍스트를 읽고 단어를 검색 한 후 다음 책을 가져옵니다. 4 ~ 8 개의 스레드가 별도의 서적에서 동시에 작업 할 수 있도록 이것을 나눕니다.자바에서 스레드를 사용하여 병렬 프로그램을 병렬로 변환 하시겠습니까?
어떤 도움이 필요합니까?
public static void main(String args[]){
String wordToSearch = "";
String[] booksOfBible;
int bookPosition = 0;
ArrayList<String> finalList = new ArrayList<String>();
getWord gW = new getWord();
getBook gB = new getBook();
checkBook cB = new checkBook();
wordToSearch = gW.getWord(wordToSearch);
booksOfBible = gB.getFileList();
//System.out.println(wordToSearch);
for(int i = 0; i < booksOfBible.length; i++){
//System.out.println(booksOfBible[i]);//Test to see if books are in order
String[] verses = gB.getNextBook(booksOfBible, bookPosition);
//System.out.println(verses[0]);//Test to see if the books are being read properly
cB.checkForWord(wordToSearch, verses, booksOfBible[i], finalList);
bookPosition++;
}
for(int i = 0; i < finalList.size(); i++){
System.out.println(finalList.get(i));
}
System.out.println("Word found " + finalList.size() + " times");
}
'사전'을 작성하여 텍스트를보다 빠르게 검색 할 수 있습니다. 이 문제에 여분의 스레드를 던지면 도움이되지 않습니다. –
* "도움이 필요하십니까?"* (특정) 질문이 있습니까? –
멀티 스레딩에 들어가기 전에 몇 가지 자습서를 읽는 것이 좋습니다. 예를 들어 [this one] (http://www.ntu.edu.sg/home/ehchua/programming/java/J5e_multithreading.html)을 참조하십시오. 병렬 프로그래밍은 매우 어려우며 단일 스레드 프로그래밍 경험은 실제로이를 준비하지 못합니다. –