*) one possible deadlock (because of nested object locks) removed in class kelondroMap

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@61 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 20 years ago
parent 58a65b60bd
commit 47e426ff7e

@ -128,12 +128,11 @@ public class kelondroMap {
class writeQueue extends Thread { class writeQueue extends Thread {
LinkedList queue; private LinkedList queue = new LinkedList();
boolean run; boolean run;
public writeQueue() { public writeQueue() {
run = true; run = true;
queue = new LinkedList();
} }
public void stack(String key) { public void stack(String key) {
@ -144,12 +143,19 @@ public class kelondroMap {
workoff(key); workoff(key);
} }
public synchronized void workoff() { public void workoff() {
if (queue.size() > 0) workoff((String) queue.removeFirst()); String newKey = null;
synchronized (this.queue) {
if (this.queue.size() > 0) {
newKey = (String) this.queue.removeFirst();
}
}
if (newKey != null) workoff(newKey);
} }
public synchronized void dequeue(String key) { public void dequeue(String key) {
// take out one entry // take out one entry
synchronized (this.queue) {
ListIterator i = queue.listIterator(); ListIterator i = queue.listIterator();
String k; String k;
while (i.hasNext()) { while (i.hasNext()) {
@ -160,6 +166,7 @@ public class kelondroMap {
} }
} }
} }
}
public void workoff(String key) { public void workoff(String key) {
//System.out.println("kelondroMap: workoff(" + dyn.entryFile.name() + ") " + key); //System.out.println("kelondroMap: workoff(" + dyn.entryFile.name() + ") " + key);

Loading…
Cancel
Save