So the ArrayList "comb" contains Strings of equal length and variations of some characters. In worst case scenario this List can contain around 100,000 words. The function checkWord(String str) takes one word as a parameter and checks whether that word is present in the Hashtable dictionary(which contains another 90,000~ words, a text file was read into this hashtable). So basically the code needs to check which of the words from List "comb" is present in the HashTable "dictionary". In worst case scenario this search takes upto 5 minutes. I want to implement Runnable and parallelise it, but unsure how to go about it.
For example: the list comb contains various misspellings of CURMUDGEON and the correct word itself. This list contains 98415 of them. CURMUEGEON CURMUEGEOH CURMUEGEOJ CURMUEGEKN etc etc. So checking if each of these words are present in the hash table takes 200 seconds. I want to bring down this time
class key implements Runnable{
public static ArrayList<String> comb;
public static Hashtable<String,String> dictionary;
public static void main(String[] args) throws IOException{
key obj = new key();
Thread thread1 = new Thread(obj);
thread1.start();
}
public static Boolean checkWord(String str){
String toCheck = str.toLowerCase();
if(dictionary.contains(toCheck)){
return true;
}
else
return false;
}
public void run(){
for(String x:comb)
if ( checkWord(x) )
filtered.add(x);
}