-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.java
More file actions
51 lines (46 loc) · 1.43 KB
/
worker.java
File metadata and controls
51 lines (46 loc) · 1.43 KB
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
package biomarker1;
/*
The class for the microsatellite search. this process runs un parallel threads
*/
import static java.lang.Math.random;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
public class worker extends Thread {
String sproblema;
String seq;
boolean busy;
int archivoNum;
printer printer;
int cnt;
public void setup(String sproblema, String seq, int archivoNum, printer printer) {
this.sproblema = new String(sproblema);
this.seq = new String(seq);
this.archivoNum = archivoNum;
this.printer = printer;
this.cnt = 0;
}
@Override
public void run() {
busy = true;
boolean done = false;
Random rn = new Random();
while (seq.contains(sproblema)) { //validation and count of the microsatellite
seq = seq.substring(seq.indexOf(sproblema) + 1);
this.cnt++;
System.gc();
done = false;
}
this.busy = false;
String line = " " + sproblema + ", hits: ," + Integer.toString(cnt) + ", Seq Num: ," + archivoNum + " , ";
System.out.println(line);
while (done == false) {
if (printer.busy == false) {
printer.print(line);
done = true;
}
for (int r = 0; r < rn.nextInt(100); r++) {
}
}
}
}