-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThreads.java
87 lines (74 loc) · 2.56 KB
/
Threads.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import static java.lang.Thread.currentThread;
import java.util.LinkedList;
import javax.swing.ImageIcon;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Raul
*/
public class Threads extends Thread {
private boolean done;
LinkedList cola;
private LinkedList resultado;
int option;
public Threads(String str, LinkedList cola, int option){
super(str);
this.option = option;
this.done = false;
this.cola = cola;
this.resultado = new LinkedList();
}
public void run() {
Thread thActual = currentThread();
if ("1".equals(this.getName()) && !done) {
try {
Interface server1 = (Interface) java.rmi.Naming.lookup("//200.1.1.2:1233/ThreadServer1");
while (cola.peek() != null) {
ImageIcon image;
image = server1.transformImages((ImageIcon) cola.poll(), option, 500);
resultado.offer(image);
//System.out.println("obtuvo imagen Cola 1 tama�o: " + cola.size());
}
if (resultado.size() != 0) {
//System.out.println("Obtuvo valor con " + resultado.size() + " elementros");
done = true;
}
} catch (Exception e) {
System.out.println("No se pudo realizar operacion");
}
}
if ("2".equals(this.getName()) && !done) {
try {
Interface server2 = (Interface) java.rmi.Naming.lookup("//200.1.2.2:1099/ThreadServer2");
while (cola.peek() != null) {
ImageIcon image;
image = server2.transformImages((ImageIcon) cola.poll(), option, 500);
resultado.offer(image);
//System.out.println("obtuvo imagen Cola 2 tama�o: " + cola.size());
}
if (resultado.size() != 0) {
// System.out.println("Obtuvo valor con " + resultado.size() + " elementros");
done = true;
}
} catch (Exception e) {
System.out.println("No se pudo realizar operacion");
}
}
}
/**
* @return the done
*/
public boolean isDone() {
return done;
}
/**
* @return the resultado
*/
public LinkedList getResultado() {
return resultado;
}
}