Skip to content

Commit

Permalink
solve multi thread load dic problem
Browse files Browse the repository at this point in the history
  • Loading branch information
piaolingxue committed Feb 27, 2014
1 parent 6201e93 commit a559e1c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main/java/com/huaban/analysis/jieba/WordDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@


public class WordDictionary {
private static WordDictionary singleInstance;
private static WordDictionary singleInstance = new WordDictionary();
private static final String MAIN_DICT = "/dict.txt";
private static String USER_DICT_SUFFIX = ".dict";

static {
singleInstance.loadDict();
}

public final TrieNode trie = new TrieNode();
public final Map<String, Double> freqs = new HashMap<String, Double>();
private Double minFreq = Double.MAX_VALUE;
Expand All @@ -30,12 +34,6 @@ private WordDictionary() {


public static WordDictionary getInstance() {
if (singleInstance == null) {
synchronized (singleInstance) {
singleInstance = new WordDictionary();
singleInstance.loadDict();
}
}
return singleInstance;
}

Expand Down

0 comments on commit a559e1c

Please sign in to comment.