MCPcopy Create free account
hub / github.com/baidu/lac / LacRunnable

Class LacRunnable

java/LacMulti.java:40–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40class LacRunnable implements Runnable{
41
42
43 public LacRunnable(LAC lac){
44 g_lac = lac;
45 }
46
47 // share model and lock
48 private LAC g_lac;
49 private Lock printLock = new ReentrantLock();
50 private Lock readLock = new ReentrantLock();
51
52 public void run() {
53 ArrayList<String> words = new ArrayList<>();
54 ArrayList<String> tags = new ArrayList<>();
55 BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
56 String query = null;
57
58 try {
59 LAC thread_lac = new LAC(g_lac);
60 while (true) {
61 readLock.lock();
62 if ((query = stdin.readLine()) == null){
63 readLock.unlock();
64 break;
65 }
66 readLock.unlock();
67 thread_lac.run(query, words, tags);
68
69 printLock.lock();
70 System.out.println(words);
71 System.out.println(tags);
72 printLock.unlock();
73 }
74 } catch (Exception e) {
75 System.out.println(e.getMessage());
76 }
77 }
78}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected