-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRunnableDemo.java
70 lines (55 loc) · 1.92 KB
/
RunnableDemo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
class RunnableDemo implements Callable<ArrayList<Result>> {
private Thread t;
private String threadName;
private ArrayList<Text> projectTextList;
private Text text1;
private int mode;
private int gapSize;
private int minNumLines;
private String databaseDir;
private String projectDir;
private ArrayList<Result> result;
@Override
public ArrayList<Result> call() throws Exception {
run();
return result;
}
public void run() {
//System.out.println("Running " + threadName );
for (int j = 0; j < projectTextList.size(); j++) {
// inner loop is the project
Text text2 = projectTextList.get(j);
ArrayList<Result> resultInner = TextCompare.textCompare(text2, text1, mode, gapSize, minNumLines, projectDir, databaseDir);
result.addAll(resultInner);
}
//System.out.println("Thread " + threadName + " exiting.");
}
public RunnableDemo( String name, ArrayList<Text> projectTextListIn, Text text1In,
int modeIn, int gapSizeIn, int minNumLinesIn, String projectDirIn, String databaseDirIn) {
threadName = name;
//System.out.println("Creating " + threadName );
projectTextList = projectTextListIn;
text1 = text1In;
mode = modeIn;
gapSizeIn = gapSize;
minNumLines = minNumLinesIn;
projectDir = projectDirIn;
databaseDir = databaseDirIn;
result = new ArrayList<Result>();
//System.out.println("Starting " + threadName );
//if (t == null) {
// t = new Thread (this, threadName);
// t.start ();
//}
}
}