1 package eu.fbk.knowledgestore.populator.naf;
2
3 import java.io.IOException;
4
5 public class finalizeThread implements Runnable {
6
7 @Override
8 public void run() {
9 while (true) {
10 if (allThreadsDied()&&nafPopulator.JobFinished) {
11 try {
12 footer();
13 nafPopulator.nullObjects();
14 return;
15 } catch (IOException e) {
16 e.printStackTrace();
17 }
18 }
19
20 }
21
22 }
23
24 private boolean allThreadsDied() {
25 boolean notFinished = true;
26 for (Thread tmp : nafPopulator.threads) {
27 if (tmp.isAlive())
28 notFinished = false;
29
30 }
31
32
33 return notFinished;
34 }
35
36 void footer() throws IOException {
37
38 if(nafPopulator.out!=null){
39 nafPopulator.out.append("Global stats:\n").append(nafPopulator.globalStats.getStats());
40 nafPopulator.out.flush();
41 }else{
42 System.err.println("Error: report file has been closed!");
43 System.err.println("The report is:");
44 System.err.println("Global stats:\n"+nafPopulator.globalStats.getStats());
45
46 }
47 }
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 }